KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > icu > util > EthiopicCalendar


1 /*
2  *******************************************************************************
3  * Copyright (C) 2005-2006, International Business Machines Corporation and *
4  * others. All Rights Reserved. *
5  *******************************************************************************
6  */

7 package com.ibm.icu.util;
8
9 import java.util.Date JavaDoc;
10 import java.util.Locale JavaDoc;
11
12 /**
13  * Implement the Ethiopic calendar system.
14  * <p>
15  * EthiopicCalendar usually should be instantiated using
16  * {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a <code>ULocale</code>
17  * with the tag <code>"@calendar=ethiopic"</code>.</p>
18  *
19  * @see com.ibm.icu.util.Calendar
20  * @draft ICU 3.4
21  * @provisional This API might change or be removed in a future release.
22  */

23 public final class EthiopicCalendar extends CECalendar
24 {
25     //jdk1.4.2 serialver
26
private static final long serialVersionUID = -2438495771339315608L;
27
28     /**
29      * Constant for ?????, the 1st month of the Ethiopic year.
30      * @draft ICU 3.4
31      * @provisional This API might change or be removed in a future release.
32      */

33     public static final int MESKEREM = 0;
34
35     /**
36      * Constant for ????, the 2nd month of the Ethiopic year.
37      * @draft ICU 3.4
38      * @provisional This API might change or be removed in a future release.
39      */

40     public static final int TEKEMT = 1;
41
42     /**
43      * Constant for ???, the 3rd month of the Ethiopic year.
44      * @draft ICU 3.4
45      * @provisional This API might change or be removed in a future release.
46      */

47     public static final int HEDAR = 2;
48
49     /**
50      * Constant for ????, the 4th month of the Ethiopic year.
51      * @draft ICU 3.4
52      * @provisional This API might change or be removed in a future release.
53      */

54     public static final int TAHSAS = 3;
55
56     /**
57      * Constant for ??, the 5th month of the Ethiopic year.
58      * @draft ICU 3.4
59      * @provisional This API might change or be removed in a future release.
60      */

61     public static final int TER = 4;
62
63     /**
64      * Constant for ????, the 6th month of the Ethiopic year.
65      * @draft ICU 3.4
66      * @provisional This API might change or be removed in a future release.
67      */

68     public static final int YEKATIT = 5;
69
70     /**
71      * Constant for ????, the 7th month of the Ethiopic year.
72      * @draft ICU 3.4
73      * @provisional This API might change or be removed in a future release.
74      */

75     public static final int MEGABIT = 6;
76
77     /**
78      * Constant for ????, the 8th month of the Ethiopic year.
79      * @draft ICU 3.4
80      * @provisional This API might change or be removed in a future release.
81      */

82     public static final int MIAZIA = 7;
83
84     /**
85      * Constant for ????, the 9th month of the Ethiopic year.
86      * @draft ICU 3.4
87      * @provisional This API might change or be removed in a future release.
88      */

89     public static final int GENBOT = 8;
90
91     /**
92      * Constant for ??, the 10th month of the Ethiopic year.
93      * @draft ICU 3.4
94      * @provisional This API might change or be removed in a future release.
95      */

96     public static final int SENE = 9;
97
98     /**
99      * Constant for ???, the 11th month of the Ethiopic year.
100      * @draft ICU 3.4
101      * @provisional This API might change or be removed in a future release.
102      */

103     public static final int HAMLE = 10;
104
105     /**
106      * Constant for ???, the 12th month of the Ethiopic year.
107      * @draft ICU 3.4
108      * @provisional This API might change or be removed in a future release.
109      */

110     public static final int NEHASSE = 11;
111
112     /**
113      * Constant for ????, the 13th month of the Ethiopic year.
114      * @draft ICU 3.4
115      * @provisional This API might change or be removed in a future release.
116      */

117     public static final int PAGUMEN = 12;
118  
119     // Up until the end of the 19th century the prevailant convention was to
120
// reference the Ethiopic Calendar from the creation of the world,
121
// \u12d3\u1218\u1270\u1361\u12d3\u1208\u121d
122
// (Amete Alem 5500 BC). As Ethiopia modernized the reference epoch from
123
// the birth of Christ (\u12d3\u1218\u1270\u1361\u121d\u1215\u1228\u1275)
124
// began to displace the creation of the
125
// world reference point. However, years before the birth of Christ are
126
// still referenced in the creation of the world system.
127
// Thus -100 \u12d3/\u121d
128
// would be rendered as 5400 \u12d3/\u12d3.
129
//
130
// The creation of the world in Ethiopic cannon was
131
// Meskerem 1, -5500 \u12d3/\u121d 00:00:00
132
// applying the birth of Christ reference and Ethiopian time conventions. This is
133
// 6 hours less than the Julian epoch reference point (noon). In Gregorian
134
// the date and time was July 18th -5493 BC 06:00 AM.
135

136     // Julian Days relative to the
137
// \u12d3\u1218\u1270\u1361\u121d\u1215\u1228\u1275 epoch
138
private static final int JD_EPOCH_OFFSET_AMETE_ALEM = -285019;
139
140     // Julian Days relative to the
141
// \u12d3\u1218\u1270\u1361\u12d3\u1208\u121d epoch
142
private static final int JD_EPOCH_OFFSET_AMETE_MIHRET = 1723856;
143
144     // initialize base class constant, common to all constructors
145
{
146         jdEpochOffset = JD_EPOCH_OFFSET_AMETE_MIHRET;
147     }
148
149     /**
150      * Constructs a default <code>EthiopicCalendar</code> using the current time
151      * in the default time zone with the default locale.
152      *
153      * @draft ICU 3.4
154      * @provisional This API might change or be removed in a future release.
155      */

156     public EthiopicCalendar() {
157         super();
158     }
159
160     /**
161      * Constructs a <code>EthiopicCalendar</code> based on the current time
162      * in the given time zone with the default locale.
163      *
164      * @param zone The time zone for the new calendar.
165      *
166      * @draft ICU 3.4
167      * @provisional This API might change or be removed in a future release.
168      */

169     public EthiopicCalendar(TimeZone zone) {
170         super(zone);
171     }
172
173     /**
174      * Constructs a <code>EthiopicCalendar</code> based on the current time
175      * in the default time zone with the given locale.
176      *
177      * @param aLocale The locale for the new calendar.
178      * @draft ICU 3.4
179      * @provisional This API might change or be removed in a future release.
180      */

181     public EthiopicCalendar(Locale JavaDoc aLocale) {
182         super(aLocale);
183     }
184
185     /**
186      * Constructs a <code>EthiopicCalendar</code> based on the current time
187      * in the default time zone with the given locale.
188      *
189      * @param locale The icu locale for the new calendar.
190      *
191      * @draft ICU 3.4
192      * @provisional This API might change or be removed in a future release.
193      */

194     public EthiopicCalendar(ULocale locale) {
195         super(locale);
196     }
197
198     /**
199      * Constructs a <code>EthiopicCalendar</code> based on the current time
200      * in the given time zone with the given locale.
201      *
202      * @param zone The time zone for the new calendar.
203      * @param aLocale The locale for the new calendar.
204      *
205      * @draft ICU 3.4
206      * @provisional This API might change or be removed in a future release.
207      */

208     public EthiopicCalendar(TimeZone zone, Locale JavaDoc aLocale) {
209         super(zone, aLocale);
210     }
211     
212     /**
213      * Constructs a <code>EthiopicCalendar</code> based on the current time
214      * in the given time zone with the given locale.
215      *
216      * @param zone The time zone for the new calendar.
217      * @param locale The icu locale for the new calendar.
218      *
219      * @draft ICU 3.4
220      * @provisional This API might change or be removed in a future release.
221      */

222     public EthiopicCalendar(TimeZone zone, ULocale locale) {
223         super(zone, locale);
224     }
225     
226     /**
227      * Constructs a <code>EthiopicCalendar</code> with the given date set
228      * in the default time zone with the default locale.
229      *
230      * @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
231      * @param month The value used to set the calendar's {@link #MONTH MONTH} time field.
232      * The value is 0-based. e.g., 0 for Meskerem.
233      * @param date The value used to set the calendar's {@link #DATE DATE} time field.
234      *
235      * @draft ICU 3.4
236      * @provisional This API might change or be removed in a future release.
237      */

238     public EthiopicCalendar(int year, int month, int date) {
239         super(year, month, date);
240     }
241
242     /**
243      * Constructs a <code>EthiopicCalendar</code> with the given date set
244      * in the default time zone with the default locale.
245      *
246      * @param date The date to which the new calendar is set.
247      *
248      * @draft ICU 3.4
249      * @provisional This API might change or be removed in a future release.
250      */

251     public EthiopicCalendar(Date JavaDoc date) {
252         super(date);
253     }
254
255     /**
256      * Constructs a <code>EthiopicCalendar</code> with the given date
257      * and time set for the default time zone with the default locale.
258      *
259      * @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
260      * @param month The value used to set the calendar's {@link #MONTH MONTH} time field.
261      * The value is 0-based. e.g., 0 for Meskerem.
262      * @param date The value used to set the calendar's {@link #DATE DATE} time field.
263      * @param hour The value used to set the calendar's {@link #HOUR_OF_DAY HOUR_OF_DAY} time field.
264      * @param minute The value used to set the calendar's {@link #MINUTE MINUTE} time field.
265      * @param second The value used to set the calendar's {@link #SECOND SECOND} time field.
266      *
267      * @draft ICU 3.4
268      * @provisional This API might change or be removed in a future release.
269      */

270     public EthiopicCalendar(int year, int month, int date, int hour,
271                             int minute, int second)
272     {
273         super(year, month, date, hour, minute, second);
274     }
275
276     /**
277      * Convert an Ethiopic year, month, and day to a Julian day.
278      *
279      * @param year the year
280      * @param month the month
281      * @param date the day
282      *
283      * @draft ICU 3.4
284      * @provisional This API might change or be removed in a future release.
285      */

286     public static int EthiopicToJD(long year, int month, int date) {
287         return ceToJD(year, month, date, JD_EPOCH_OFFSET_AMETE_MIHRET);
288     }
289     
290     /**
291      * @internal ICU 3.4
292      * @deprecated This API is ICU internal only.
293      */

294     public static Integer JavaDoc[] getDateFromJD(int julianDay) {
295         return getDateFromJD(julianDay, JD_EPOCH_OFFSET_AMETE_MIHRET);
296     }
297     
298     /**
299      * Set Alem or Mihret era.
300      *
301      * @param onOff Set Amete Alem era if true, otherwise set Amete Mihret era.
302      *
303      * @draft ICU 3.4
304      * @provisional This API might change or be removed in a future release.
305      */

306     public void setAmeteAlemEra(boolean onOff) {
307         this.jdEpochOffset = onOff
308         ? JD_EPOCH_OFFSET_AMETE_ALEM
309         : JD_EPOCH_OFFSET_AMETE_MIHRET;
310     }
311     
312     /**
313      * Return true if this calendar is set to the Amete Alem era.
314      *
315      * @return true if set to the Amete Alem era.
316      *
317      * @draft ICU 3.4
318      * @provisional This API might change or be removed in a future release.
319      */

320     public boolean isAmeteAlemEra() {
321         return this.jdEpochOffset == JD_EPOCH_OFFSET_AMETE_ALEM;
322     }
323
324     /**
325      * Return the current Calendar type.
326      * @return type of calendar (gregorian, etc.)
327      * @internal ICU 3.4
328      * @deprecated This API is ICU internal only.
329      */

330     public String JavaDoc getType() {
331         return "ethiopic";
332     }
333 }
334
335
Popular Tags