2 *******************************************************************************
3 * Copyright (C) 2012, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
7 package com.ibm.icu.util;
11 import com.ibm.icu.util.ULocale.Category;
14 * <code>DangiCalendar</code> is a concrete subclass of {@link Calendar}
15 * that implements a traditional Korean calendar.
18 * @deprecated This API is ICU internal only.
20 public class DangiCalendar extends ChineseCalendar {
22 private static final long serialVersionUID = 8156297445349501985L;
25 * The start year of the Korean traditional calendar (Dan-gi) is the inaugural
26 * year of Dan-gun (BC 2333).
28 private static final int DANGI_EPOCH_YEAR = -2332;
31 * The time zone used for performing astronomical computations for
32 * Dangi calendar. In Korea various timezones have been used historically
33 * (cf. http://www.math.snu.ac.kr/~kye/others/lunar.html):
36 * 1908/04/01 - 1911/12/31: GMT+8.5
37 * 1912/01/01 - 1954/03/20: GMT+9
38 * 1954/03/21 - 1961/08/09: GMT+8.5
39 * 1961/08/10 - : GMT+9
41 * Note that, in 1908-1911, the government did not apply the timezone change
42 * but used GMT+8. In addition, 1954-1961's timezone change does not affect
43 * the lunar date calculation. Therefore, the following simpler rule works:
48 * Unfortunately, our astronomer's approximation doesn't agree with the
49 * references (http://www.math.snu.ac.kr/~kye/others/lunar.html and
50 * http://astro.kasi.re.kr/Life/ConvertSolarLunarForm.aspx?MenuID=115)
51 * in 1897/7/30. So the following ad hoc fix is used here:
58 private static final TimeZone KOREA_ZONE;
61 InitialTimeZoneRule initialTimeZone = new InitialTimeZoneRule("GMT+8", 8 * ONE_HOUR, 0);
62 long[] millis1897 = { (1897 - 1970) * 365L * ONE_DAY }; // some days of error is not a problem here
63 long[] millis1898 = { (1898 - 1970) * 365L * ONE_DAY }; // some days of error is not a problem here
64 long[] millis1912 = { (1912 - 1970) * 365L * ONE_DAY }; // this doesn't create an issue for 1911/12/20
65 TimeZoneRule rule1897 = new TimeArrayTimeZoneRule("Korean 1897", 7 * ONE_HOUR, 0, millis1897,
66 DateTimeRule.STANDARD_TIME);
67 TimeZoneRule rule1898to1911 = new TimeArrayTimeZoneRule("Korean 1898-1911", 8 * ONE_HOUR, 0, millis1898,
68 DateTimeRule.STANDARD_TIME);
69 TimeZoneRule ruleFrom1912 = new TimeArrayTimeZoneRule("Korean 1912-", 9 * ONE_HOUR, 0, millis1912,
70 DateTimeRule.STANDARD_TIME);
72 RuleBasedTimeZone tz = new RuleBasedTimeZone("KOREA_ZONE", initialTimeZone);
73 tz.addTransitionRule(rule1897);
74 tz.addTransitionRule(rule1898to1911);
75 tz.addTransitionRule(ruleFrom1912);
81 * Construct a <code>DangiCalendar</code> with the default time zone and locale.
84 * @deprecated This API is ICU internal only.
86 public DangiCalendar() {
87 this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
91 * Construct a <code>DangiCalendar</code> with the give date set in the default time zone
92 * with the default locale.
93 * @param date The date to which the new calendar is set.
96 * @deprecated This API is ICU internal only.
98 public DangiCalendar(Date date) {
99 this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
104 * Construct a <code>DangiCalendar</code> based on the current time
105 * with the given time zone with the given locale.
106 * @param zone the given time zone
107 * @param locale the given locale
110 * @deprecated This API is ICU internal only.
112 public DangiCalendar(TimeZone zone, ULocale locale) {
113 super(zone, locale, DANGI_EPOCH_YEAR, KOREA_ZONE);
120 * @deprecated This API is ICU internal only.
122 public String getType() {