|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.icu.util.Calendar
com.ibm.icu.util.ChineseCalendar
public class ChineseCalendar
ChineseCalendar
is a concrete subclass of Calendar
that implements a traditional Chinese calendar. The traditional Chinese
calendar is a lunisolar calendar: Each month starts on a new moon, and
the months are numbered according to solar events, specifically, to
guarantee that month 11 always contains the winter solstice. In order
to accomplish this, leap months are inserted in certain years. Leap
months are numbered the same as the month they follow. The decision of
which month is a leap month depends on the relative movements of the sun
and moon.
This class defines one addition field beyond those defined by
Calendar
: The IS_LEAP_MONTH
field takes the
value of 0 for normal months, or 1 for leap months.
All astronomical computations are performed with respect to a time zone of GMT+8:00 and a longitude of 120 degrees east. Although some calendars implement a historically more accurate convention of using Beijing's local longitude (116 degrees 25 minutes east) and time zone (GMT+7:45:40) for dates before 1929, we do not implement this here.
Years are counted in two different ways in the Chinese calendar. The
first method is by sequential numbering from the 61st year of the reign
of Huang Di, 2637 BCE, which is designated year 1 on the Chinese
calendar. The second method uses 60-year cycles from the same starting
point, which is designated year 1 of cycle 1. In this class, the
EXTENDED_YEAR
field contains the sequential year count.
The ERA
field contains the cycle number, and the
YEAR
field contains the year of the cycle, a value between
1 and 60.
There is some variation in what is considered the starting point of the calendar, with some sources starting in the first year of the reign of Huang Di, rather than the 61st. This gives continuous year numbers 60 years greater and cycle numbers one greater than what this class implements.
Because ChineseCalendar
defines an additional field and
redefines the way the ERA
field is used, it requires a new
format class, ChineseDateFormat
. As always, use the
methods DateFormat.getXxxInstance(Calendar cal,...)
to
obtain a formatter for this calendar.
References:
This class should not be subclassed.
ChineseCalendar usually should be instantiated using
Calendar.getInstance(ULocale)
passing in a ULocale
with the tag "@calendar=chinese"
.
ChineseDateFormat
,
Calendar
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class com.ibm.icu.util.Calendar |
---|
Calendar.FormatConfiguration |
Field Summary | |
---|---|
static int |
IS_LEAP_MONTH
Field indicating whether or not the current month is a leap month. |
Fields inherited from class com.ibm.icu.util.Calendar |
---|
AM, AM_PM, APRIL, AUGUST, BASE_FIELD_COUNT, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DOW_LOCAL, DST_OFFSET, EPOCH_JULIAN_DAY, ERA, EXTENDED_YEAR, FEBRUARY, FRIDAY, GREATEST_MINIMUM, HOUR, HOUR_OF_DAY, INTERNALLY_SET, JAN_1_1_JULIAN_DAY, JANUARY, JULIAN_DAY, JULY, JUNE, LEAST_MAXIMUM, MARCH, MAX_DATE, MAX_FIELD_COUNT, MAX_JULIAN, MAX_MILLIS, MAXIMUM, MAY, MILLISECOND, MILLISECONDS_IN_DAY, MIN_DATE, MIN_JULIAN, MIN_MILLIS, MINIMUM, MINIMUM_USER_STAMP, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, PM, RESOLVE_REMAP, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, UNSET, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, WEEKDAY, WEEKEND, WEEKEND_CEASE, WEEKEND_ONSET, YEAR, YEAR_WOY, ZONE_OFFSET |
Constructor Summary | |
---|---|
ChineseCalendar()
Construct a ChineseCalendar with the default time zone and locale. |
|
ChineseCalendar(Date date)
Construct a ChineseCalendar with the give date set in the default time zone
with the default locale. |
|
ChineseCalendar(int year,
int month,
int isLeapMonth,
int date)
Constructs a ChineseCalendar with the given date set
in the default time zone with the default locale. |
|
ChineseCalendar(int year,
int month,
int isLeapMonth,
int date,
int hour,
int minute,
int second)
Constructs a ChineseCalendar with the given date
and time set for the default time zone with the default locale. |
|
ChineseCalendar(Locale aLocale)
Constructs a ChineseCalendar based on the current time
in the default time zone with the given locale. |
|
ChineseCalendar(TimeZone zone)
Construct a ChineseCalendar based on the current time
in the given time zone with the default locale. |
|
ChineseCalendar(TimeZone zone,
Locale aLocale)
Construct a ChineseCalendar based on the current time
in the given time zone with the given locale. |
|
ChineseCalendar(TimeZone zone,
ULocale locale)
Construct a ChineseCalendar based on the current time
with the given time zone with the given locale. |
|
ChineseCalendar(ULocale locale)
Constructs a ChineseCalendar based on the current time
in the default time zone with the given locale. |
Method Summary | |
---|---|
void |
add(int field,
int amount)
Override Calendar to handle leap months properly. |
protected int[][][] |
getFieldResolutionTable()
Override Calendar to add IS_LEAP_MONTH to the field resolution table. |
String |
getType()
Return the current Calendar type. |
protected void |
handleComputeFields(int julianDay)
Override Calendar to compute several fields specific to the Chinese calendar system. |
protected int |
handleComputeMonthStart(int eyear,
int month,
boolean useMonth)
Return the Julian day number of day before the first day of the given month in the given extended year. |
protected int[] |
handleCreateFields()
Override Calendar to allocate our additional field. |
protected DateFormat |
handleGetDateFormat(String pattern,
ULocale locale)
Framework method to create a calendar-specific DateFormat object using the the given pattern. |
protected int |
handleGetExtendedYear()
Implement abstract Calendar method to return the extended year defined by the current fields. |
protected int |
handleGetLimit(int field,
int limitType)
Override Calendar to return the limit value for the given field. |
protected int |
handleGetMonthLength(int extendedYear,
int month)
Override Calendar method to return the number of days in the given extended year and month. |
void |
roll(int field,
int amount)
Override Calendar to handle leap months properly. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int IS_LEAP_MONTH
Constructor Detail |
---|
public ChineseCalendar()
ChineseCalendar
with the default time zone and locale.
public ChineseCalendar(Date date)
ChineseCalendar
with the give date set in the default time zone
with the default locale.
date
- The date to which the new calendar is set.public ChineseCalendar(int year, int month, int isLeapMonth, int date)
ChineseCalendar
with the given date set
in the default time zone with the default locale.
year
- The value used to set the calendar's YEAR
time field.month
- The value used to set the calendar's MONTH
time field.
The value is 0-based. e.g., 0 for January.isLeapMonth
- The value used to set the Chiense calendar's (@link #IS_LEAP_MONTH)
time field.date
- The value used to set the calendar's DATE
time field.public ChineseCalendar(int year, int month, int isLeapMonth, int date, int hour, int minute, int second)
ChineseCalendar
with the given date
and time set for the default time zone with the default locale.
year
- the value used to set the YEAR
time field in the calendar.month
- the value used to set the MONTH
time field in the calendar.
Note that the month value is 0-based. e.g., 0 for January.isLeapMonth
- the value used to set the IS_LEAP_MONTH
time field
in the calendar.date
- the value used to set the DATE
time field in the calendar.hour
- the value used to set the HOUR_OF_DAY
time field
in the calendar.minute
- the value used to set the MINUTE
time field
in the calendar.second
- the value used to set the SECOND
time field
in the calendar.public ChineseCalendar(Locale aLocale)
ChineseCalendar
based on the current time
in the default time zone with the given locale.
aLocale
- The given localepublic ChineseCalendar(TimeZone zone)
ChineseCalendar
based on the current time
in the given time zone with the default locale.
zone
- the given time zonepublic ChineseCalendar(TimeZone zone, Locale aLocale)
ChineseCalendar
based on the current time
in the given time zone with the given locale.
zone
- the given time zoneaLocale
- the given localepublic ChineseCalendar(ULocale locale)
ChineseCalendar
based on the current time
in the default time zone with the given locale.
locale
- the given ulocalepublic ChineseCalendar(TimeZone zone, ULocale locale)
ChineseCalendar
based on the current time
with the given time zone with the given locale.
zone
- the given time zonelocale
- the given ulocaleMethod Detail |
---|
protected int[] handleCreateFields()
handleCreateFields
in class Calendar
protected int handleGetLimit(int field, int limitType)
handleGetLimit
in class Calendar
field
- one of the above field numberslimitType
- one of MINIMUM
, GREATEST_MINIMUM
,
LEAST_MAXIMUM
, or MAXIMUM
protected int handleGetExtendedYear()
handleGetExtendedYear
in class Calendar
protected int handleGetMonthLength(int extendedYear, int month)
Note: This method also reads the IS_LEAP_MONTH field to determine whether or not the given month is a leap month.
handleGetMonthLength
in class Calendar
protected DateFormat handleGetDateFormat(String pattern, ULocale locale)
handleGetDateFormat
in class Calendar
pattern
- the pattern, specific to the DateFormat
subclasslocale
- the locale for which the symbols should be drawn
DateFormat
appropriate to this calendarprotected int[][][] getFieldResolutionTable()
getFieldResolutionTable
in class Calendar
Calendar.resolveFields(int[][][])
public void add(int field, int amount)
add
in class Calendar
field
- the time field.amount
- the amount to add to the field.Calendar.roll(int, int)
public void roll(int field, int amount)
roll
in class Calendar
field
- the calendar field to roll.amount
- the amount by which the field should be rolled.Calendar.roll(int, boolean)
,
Calendar.add(int, int)
protected void handleComputeFields(int julianDay)
Compute the ChineseCalendar-specific field IS_LEAP_MONTH.
handleComputeFields
in class Calendar
protected int handleComputeMonthStart(int eyear, int month, boolean useMonth)
Note: This method reads the IS_LEAP_MONTH field to determine whether the given month is a leap month.
handleComputeMonthStart
in class Calendar
eyear
- the extended yearmonth
- the zero-based month. The month is also determined
by reading the IS_LEAP_MONTH field.useMonth
- if false, compute the day before the first day of
the given year, otherwise, compute the day before the first day of
the given month
public String getType()
getType
in class Calendar
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |