JapaneseCalendar is a subclass of GregorianCalendar
that numbers years and eras based on the reigns of the Japanese emperors.
The Japanese calendar is identical to the Gregorian calendar in all respects
except for the year and era. The ascension of each emperor to the throne
begins a new era, and the years of that era are numbered starting with the
year of ascension as year 1.
Note that in the year of an imperial ascension, there are two possible sets of year and era values: that for the old era and for the new. For example, a new era began on January 7, 1989 AD. Strictly speaking, the first six days of that year were in the Showa era, e.g. "January 6, 64 Showa", while the rest of the year was in the Heisei era, e.g. "January 7, 1 Heisei". This class handles this distinction correctly when computing dates. However, in lenient mode either form of date is acceptable as input.
In modern times, eras have started on January 8, 1868 AD, Gregorian (Meiji),
July 30, 1912 (Taisho), December 25, 1926 (Showa), and January 7, 1989 (Heisei). Constants
for these eras, suitable for use in the ERA field, are provided
in this class. Note that the number used for each era is more or
less arbitrary. Currently, the era starting in 645 AD is era #0; however this
may change in the future. Use the predefined constants rather than using actual,
absolute numbers.
Since ICU4J 63, start date of each era is imported from CLDR. CLDR era data may contain tentative era in near future with placeholder names. By default, such era data is not enabled. ICU4J users who want to test the behavior of the future era can enable this by one of following settings (in the priority order):
ICU_ENABLE_TENTATIVE_ERA=true.ICU_ENABLE_TENTATIVE_ERA=true.jdk.calendar.japanese.supplemental.era=xxx.
(Note: This configuration is used for specifying a new era's start date and
names in OpenJDK. ICU4J implementation enables the CLDR tentative era when
this property is defined, but it does not use the start date and names specified
by the property value.)This class should not be subclassed.
JapaneseCalendar usually should be instantiated using
com. passing in a ULocale
with the tag "@calendar=japanese".
com.ibm.icu.util.GregorianCalendar , com.ibm.icu.util.Calendar
| Modifier and Type | Field and Description |
|---|---|
| public static final int | |
| private static final EraRules | |
| private static final int | |
| public static final int | HEISEI
Constant for the era starting on Jan. |
| public static final int | MEIJI
Constant for the era starting on Sept. |
| public static final int | REIWA
Constant for the era starting on May 1, 2019 AD. |
| private static final long | |
| public static final int | SHOWA
Constant for the era starting on Dec. |
| public static final int | TAISHO
Constant for the era starting on July 30, 1912 AD. |
| Access | Constructor and Description |
|---|---|
| public | JapaneseCalendar()
Constructs a default |
| public | JapaneseCalendar(TimeZone
the given time zone. zone)Constructs a |
| public | JapaneseCalendar(Locale
the given locale. aLocale)Constructs a |
| public | JapaneseCalendar(ULocale
the given ulocale. locale)Constructs a |
| public | JapaneseCalendar(TimeZone
the given time zone. zone, Locale the given locale. aLocale)Constructs a |
| public | JapaneseCalendar(TimeZone
the given time zone. zone, ULocale the given ulocale. locale)Constructs a |
| public | JapaneseCalendar(Date
The date to which the new calendar is set. date)Constructs a |
| public | JapaneseCalendar(int era, int
The value used to set the calendar's year, int YEAR field,
in terms of the era.The value used to set the calendar's month, int MONTH field.
The value is 0-based. e.g., 0 for January.The value used to set the calendar's DATE field. date)Constructs a |
| public | JapaneseCalendar(int
The value used to set the calendar's year, int YEAR field,
in the era Heisei, the most current at the time this
class was last updated.The value used to set the calendar's month, int MONTH field.
The value is 0-based. e.g., 0 for January.The value used to set the calendar's date)DATE field.Constructs a |
| public | JapaneseCalendar(int
The value used to set the calendar's year, int YEAR time field,
in the era Heisei, the most current at the time of this
writing.The value used to set the calendar's month, int MONTH time field.
The value is 0-based. e.g., 0 for January.The value used to set the calendar's date, int DATE time field.The value used to set the calendar's hour, int HOUR_OF_DAY time field.The value used to set the calendar's minute, int MINUTE time field.The value used to set the calendar's second)SECOND time field.Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | enableTentativeEra()
Deprecated
This API is ICU internal only.
Check environment variable that enables use of future eras.
|
| public int | getActualMaximum(int
the field whose maximum is desired field)Overrides com. |
| protected int | Returns: the default day of the monththe extendedYear, as returned by handleGetExtendedYear extendedYear, int the month, as returned by getDefaultMonthInYear month)
Called by handleComputeJulianDay.
|
| protected int | Returns: the default monththe extendedYear, as returned by handleGetExtendedYear extendedYear)
Called by handleComputeJulianDay.
|
| public String | |
| protected void | handleComputeFields(int julianDay)
Overrides com. |
| protected int | handleGetExtendedYear()
Overrides com. |
| protected int | handleGetLimit(int
one of the above field numbers field, int one of limitType)MINIMUM, GREATEST_MINIMUM,
LEAST_MAXIMUM, or MAXIMUMOverrides com. |
| public boolean | haveDefaultCentury()
Overrides com.
Deprecated
This API is ICU internal only.
Returns if two digit representation of year in this calendar type
customarily implies a default century (i.e. 03 -> 2003).
|
| CURRENT_ERA | back to summary |
|---|---|
public static final int CURRENT_ERA
| |
| ERA_RULES | back to summary |
|---|---|
| private static final EraRules ERA_RULES | |
| GREGORIAN_EPOCH | back to summary |
|---|---|
| private static final int GREGORIAN_EPOCH | |
| HEISEI | back to summary |
|---|---|
| public static final int HEISEI Constant for the era starting on Jan. 7, 1989 AD.
| |
| MEIJI | back to summary |
|---|---|
| public static final int MEIJI Constant for the era starting on Sept. 8, 1868 AD.
| |
| REIWA | back to summary |
|---|---|
| public static final int REIWA Constant for the era starting on May 1, 2019 AD.
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| SHOWA | back to summary |
|---|---|
| public static final int SHOWA Constant for the era starting on Dec. 25, 1926 AD.
| |
| TAISHO | back to summary |
|---|---|
| public static final int TAISHO Constant for the era starting on July 30, 1912 AD.
| |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar() Constructs a default
| |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(TimeZone zone) Constructs a | |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(Locale aLocale) Constructs a | |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(ULocale locale) Constructs a | |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(TimeZone zone, Locale aLocale) Constructs a | |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(TimeZone zone, ULocale locale) Constructs a | |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(Date date) Constructs a | |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(int era, int year, int month, int date) Constructs a
| |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(int year, int month, int date) Constructs a
| |
| JapaneseCalendar | back to summary |
|---|---|
| public JapaneseCalendar(int year, int month, int date, int hour, int minute, int second) Constructs a
| |
| enableTentativeEra | back to summary |
|---|---|
| public static boolean enableTentativeEra()
Deprecated This API is ICU internal only. Check environment variable that enables use of future eras.
| |
| getActualMaximum | back to summary |
|---|---|
| public int getActualMaximum(int field) Overrides com. Doc from com. Return the maximum value that this field could have, given the current date. For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar, for some years the actual maximum for MONTH is 12, and for others 13.
| |
| getDefaultDayInMonth | back to summary |
|---|---|
| protected int getDefaultDayInMonth(int extendedYear, int month) Overrides com. Called by handleComputeJulianDay. Returns the default day (1-based) for the month, taking currently-set year and era into account. Defaults to 1 for Gregorian.
| |
| getDefaultMonthInYear | back to summary |
|---|---|
| protected int getDefaultMonthInYear(int extendedYear) Overrides com. Called by handleComputeJulianDay. Returns the default month (0-based) for the year, taking year and era into account. Defaults to 0 (JANUARY) for Gregorian. | |
| getType | back to summary |
|---|---|
| public String getType() Overrides com. Doc from com. ICU See type="old type name" for the calendar attribute of locale IDs at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
| |
| handleComputeFields | back to summary |
|---|---|
| protected void handleComputeFields(int julianDay) Overrides com. Doc from com. Override Calendar to compute several fields specific to the hybrid Gregorian-Julian calendar system. These are:
| |
| handleGetExtendedYear | back to summary |
|---|---|
| protected int handleGetExtendedYear() Overrides com. Doc from com. Returns the extended year defined by the current fields. This will use the EXTENDED_YEAR field or the YEAR and supra-year fields (such as ERA) specific to the calendar system, depending on which set of fields is newer. | |
| handleGetLimit | back to summary |
|---|---|
| protected int handleGetLimit(int field, int limitType) Overrides com. Override GregorianCalendar. We should really handle YEAR_WOY and EXTENDED_YEAR here too to implement the 1..5000000 range, but it's not critical.
| |
| haveDefaultCentury | back to summary |
|---|---|
| public boolean haveDefaultCentury() Overrides com. Doc from com. Deprecated This API is ICU internal only. Returns if two digit representation of year in this calendar type
customarily implies a default century (i.e. 03 -> 2003).
The default implementation returns
| |