1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ************************************************************************** 6 * Copyright (C) 2008-2014, Google, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 ************************************************************************** 9 */ 10 package ohos.global.icu.util; 11 12 import java.io.InvalidObjectException; 13 import java.io.ObjectStreamException; 14 15 16 /** 17 * Measurement unit for time units. 18 * @see TimeUnitAmount 19 * @see TimeUnit 20 * @author markdavis 21 */ 22 public class TimeUnit extends MeasureUnit { 23 private static final long serialVersionUID = -2839973855554750484L; 24 25 /** 26 * Here for serialization backward compatibility only. 27 */ 28 private final int index; 29 TimeUnit(String type, String code)30 TimeUnit(String type, String code) { 31 super(type, code); 32 index = 0; 33 } 34 35 /** 36 * @return the available values 37 */ values()38 public static TimeUnit[] values() { 39 return new TimeUnit[] { SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR }; 40 } 41 writeReplace()42 private Object writeReplace() throws ObjectStreamException { 43 return new MeasureUnitProxy(type, subType); 44 } 45 46 // For backward compatibility only readResolve()47 private Object readResolve() throws ObjectStreamException { 48 // The old index field used to uniquely identify the time unit. 49 switch (index) { 50 case 6: 51 return SECOND; 52 case 5: 53 return MINUTE; 54 case 4: 55 return HOUR; 56 case 3: 57 return DAY; 58 case 2: 59 return WEEK; 60 case 1: 61 return MONTH; 62 case 0: 63 return YEAR; 64 default: 65 throw new InvalidObjectException("Bad index: " + index); 66 } 67 } 68 } 69