2 *******************************************************************************
\r
3 * Copyright (C) 2005-2008, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
8 package com.ibm.icu.util;
\r
10 import java.util.Date;
\r
11 import java.util.Locale;
\r
14 * Implement the Coptic calendar system.
\r
16 * CopticCalendar usually should be instantiated using
\r
17 * {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a <code>ULocale</code>
\r
18 * with the tag <code>"@calendar=coptic"</code>.</p>
\r
20 * @see com.ibm.icu.util.Calendar
\r
23 public final class CopticCalendar extends CECalendar
\r
25 // jdk1.4.2 serialver
\r
26 private static final long serialVersionUID = 5903818751846742911L;
\r
29 * Constant for ωογτ/تﻮﺗ,
\r
30 * the 1st month of the Coptic year.
\r
33 public static final int TOUT = 0;
\r
36 * Constant for Παοπι/ﻪﺑﺎﺑ,
\r
37 * the 2nd month of the Coptic year.
\r
40 public static final int BABA = 1;
\r
43 * Constant for Αθορ/رﻮﺗﺎﻫ,
\r
44 * the 3rd month of the Coptic year.
\r
47 public static final int HATOR = 2;
\r
50 * Constant for Χοιακ/ﻚﻬﻴﻛ,
\r
51 * the 4th month of the Coptic year.
\r
54 public static final int KIAHK = 3;
\r
57 * Constant for Τωβι/طﻮﺒﻫ,
\r
58 * the 5th month of the Coptic year.
\r
61 public static final int TOBA = 4;
\r
64 * Constant for Μεϣιρ/ﺮﻴﺸﻣأ,
\r
65 * the 6th month of the Coptic year.
\r
68 public static final int AMSHIR = 5;
\r
71 * Constant for Παρεμϩατ/تﺎﻬﻣﺮﺑ,
\r
72 * the 7th month of the Coptic year.
\r
75 public static final int BARAMHAT = 6;
\r
78 * Constant for Φαρμοθι/هدﻮﻣﺮﺑ,
\r
79 * the 8th month of the Coptic year.
\r
82 public static final int BARAMOUDA = 7;
\r
85 * Constant for Παϣαν/ﺲﻨﺸﺑ,
\r
86 * the 9th month of the Coptic year.
\r
89 public static final int BASHANS = 8;
\r
92 * Constant for Παωνι/ﻪﻧؤﻮﺑ,
\r
93 * the 10th month of the Coptic year.
\r
96 public static final int PAONA = 9;
\r
99 * Constant for Επηπ/ﺐﻴﺑأ,
\r
100 * the 11th month of the Coptic year.
\r
103 public static final int EPEP = 10;
\r
106 * Constant for Μεϲωρη/ىﺮﺴﻣ,
\r
107 * the 12th month of the Coptic year.
\r
110 public static final int MESRA = 11;
\r
113 * Constant for Πικογϫι
\r
114 * μαβοτ/ﺮﻴﻐﺼﻟا
\r
115 * ﺮﻬﺸﻟا,
\r
116 * the 13th month of the Coptic year.
\r
119 public static final int NASIE = 12;
\r
121 private static final int JD_EPOCH_OFFSET = 1824665;
\r
124 private static final int BCE = 0;
\r
125 private static final int CE = 1;
\r
128 * Constructs a default <code>CopticCalendar</code> using the current time
\r
129 * in the default time zone with the default locale.
\r
132 public CopticCalendar() {
\r
137 * Constructs a <code>CopticCalendar</code> based on the current time
\r
138 * in the given time zone with the default locale.
\r
140 * @param zone The time zone for the new calendar.
\r
143 public CopticCalendar(TimeZone zone) {
\r
148 * Constructs a <code>CopticCalendar</code> based on the current time
\r
149 * in the default time zone with the given locale.
\r
151 * @param aLocale The locale for the new calendar.
\r
154 public CopticCalendar(Locale aLocale) {
\r
159 * Constructs a <code>CopticCalendar</code> based on the current time
\r
160 * in the default time zone with the given locale.
\r
162 * @param locale The icu locale for the new calendar.
\r
165 public CopticCalendar(ULocale locale) {
\r
170 * Constructs a <code>CopticCalendar</code> based on the current time
\r
171 * in the given time zone with the given locale.
\r
173 * @param zone The time zone for the new calendar.
\r
174 * @param aLocale The locale for the new calendar.
\r
177 public CopticCalendar(TimeZone zone, Locale aLocale) {
\r
178 super(zone, aLocale);
\r
182 * Constructs a <code>CopticCalendar</code> based on the current time
\r
183 * in the given time zone with the given locale.
\r
185 * @param zone The time zone for the new calendar.
\r
186 * @param locale The icu locale for the new calendar.
\r
189 public CopticCalendar(TimeZone zone, ULocale locale) {
\r
190 super(zone, locale);
\r
194 * Constructs a <code>CopticCalendar</code> with the given date set
\r
195 * in the default time zone with the default locale.
\r
197 * @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
\r
198 * @param month The value used to set the calendar's {@link #MONTH MONTH} time field.
\r
199 * The value is 0-based. e.g., 0 for Tout.
\r
200 * @param date The value used to set the calendar's {@link #DATE DATE} time field.
\r
203 public CopticCalendar(int year, int month, int date) {
\r
204 super(year, month, date);
\r
208 * Constructs a <code>CopticCalendar</code> with the given date set
\r
209 * in the default time zone with the default locale.
\r
211 * @param date The date to which the new calendar is set.
\r
214 public CopticCalendar(Date date) {
\r
219 * Constructs a <code>CopticCalendar</code> with the given date
\r
220 * and time set for the default time zone with the default locale.
\r
222 * @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
\r
223 * @param month The value used to set the calendar's {@link #MONTH MONTH} time field.
\r
224 * The value is 0-based. e.g., 0 for Tout.
\r
225 * @param date The value used to set the calendar's {@link #DATE DATE} time field.
\r
226 * @param hour The value used to set the calendar's {@link #HOUR_OF_DAY HOUR_OF_DAY} time field.
\r
227 * @param minute The value used to set the calendar's {@link #MINUTE MINUTE} time field.
\r
228 * @param second The value used to set the calendar's {@link #SECOND SECOND} time field.
\r
231 public CopticCalendar(int year, int month, int date, int hour,
\r
232 int minute, int second) {
\r
233 super(year, month, date, hour, minute, second);
\r
240 public String getType() {
\r
247 * @deprecated This API is ICU internal only.
\r
249 protected int handleGetExtendedYear() {
\r
251 if (newerField(EXTENDED_YEAR, YEAR) == EXTENDED_YEAR) {
\r
252 eyear = internalGet(EXTENDED_YEAR, 1); // Default to year 1
\r
254 // The year defaults to the epoch start, the era to AD
\r
255 int era = internalGet(ERA, CE);
\r
257 eyear = 1 - internalGet(YEAR, 1); // Convert to extended year
\r
259 eyear = internalGet(YEAR, 1); // Default to year 1
\r
268 * @deprecated This API is ICU internal only.
\r
270 protected void handleComputeFields(int julianDay) {
\r
272 int[] fields = new int[3];
\r
273 jdToCE(julianDay, getJDEpochOffset(), fields);
\r
279 if (fields[0] <= 0) {
\r
281 year = 1 - fields[0];
\r
287 internalSet(EXTENDED_YEAR, fields[0]);
\r
288 internalSet(ERA, era);
\r
289 internalSet(YEAR, year);
\r
290 internalSet(MONTH, fields[1]);
\r
291 internalSet(DAY_OF_MONTH, fields[2]);
\r
292 internalSet(DAY_OF_YEAR, (30 * fields[1]) + fields[2]);
\r
298 * @deprecated This API is ICU internal only.
\r
300 protected int getJDEpochOffset() {
\r
301 return JD_EPOCH_OFFSET;
\r
305 * Convert an Coptic year, month, and day to a Julian day.
\r
307 * @param year the year
\r
308 * @param month the month
\r
309 * @param date the day
\r
310 * @draft ICU 3.4 (retain)
\r
311 * @provisional This API might change or be removed in a future release.
\r
313 // The equivalent operation can be done by public Calendar API.
\r
314 // This API was accidentally marked as @draft, but we have no good
\r
315 // reason to keep this. For now, we leave it as is, but may be
\r
316 // removed in future. 2008-03-21 yoshito
\r
317 public static int copticToJD(long year, int month, int date) {
\r
318 return ceToJD(year, month, date, JD_EPOCH_OFFSET);
\r