]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_4_2-src/main/classes/core/src/com/ibm/icu/util/TimeUnit.java
go
[Dictionary.git] / jars / icu4j-4_4_2-src / main / classes / core / src / com / ibm / icu / util / TimeUnit.java
1 /*\r
2  **************************************************************************\r
3  * Copyright (C) 2008-2009, Google, International Business Machines\r
4  * Corporation and others. All Rights Reserved.\r
5  **************************************************************************\r
6  */\r
7 package com.ibm.icu.util;\r
8 \r
9 /**\r
10  * Measurement unit for time units.\r
11  * @see TimeUnitAmount\r
12  * @see TimeUnit\r
13  * @author markdavis\r
14  * @stable ICU 4.0\r
15  */\r
16 public class TimeUnit extends MeasureUnit {\r
17     /** \r
18      * Supports selected time duration units\r
19      */\r
20     private String name;\r
21 \r
22     private static TimeUnit[] values = new TimeUnit[7]; // adjust count if new items are added\r
23     private static int valueCount = 0;\r
24 \r
25     /** \r
26      * Constant value for supported time unit.\r
27      * @stable ICU 4.0\r
28      */\r
29     public static TimeUnit\r
30     SECOND = new TimeUnit("second"),\r
31     MINUTE = new TimeUnit("minute"),\r
32     HOUR = new TimeUnit("hour"),\r
33     DAY = new TimeUnit("day"),\r
34     WEEK = new TimeUnit("week"),\r
35     MONTH = new TimeUnit("month"),\r
36     YEAR = new TimeUnit("year");\r
37 \r
38     private TimeUnit(String name) {\r
39         this.name = name;\r
40         values[valueCount++] = this; // store in values array\r
41     }\r
42 \r
43     /**\r
44      * @return the available values\r
45      * @stable ICU 4.0\r
46      */\r
47     public static TimeUnit[] values() {\r
48         return values.clone();\r
49     }\r
50 \r
51     /**\r
52      * A string representation for debugging.\r
53      * It is for debugging purpose. The value might change.\r
54      * Please do not count on the value.\r
55      * @stable ICU 4.0\r
56      */\r
57     public String toString() {\r
58         return name;\r
59     }\r
60 }\r