JapaneseImperialCalendar implements a Japanese
calendar system in which the imperial era-based year numbering is
supported from the Meiji era. The following are the eras supported
by this calendar system.
ERA value Era name Since (in Gregorian)
------------------------------------------------------
0 N/A N/A
1 Meiji 1868-01-01T00:00:00 local time
2 Taisho 1912-07-30T00:00:00 local time
3 Showa 1926-12-25T00:00:00 local time
4 Heisei 1989-01-08T00:00:00 local time
5 Reiwa 2019-05-01T00:00:00 local time
------------------------------------------------------
ERA value 0 specifies the years before Meiji and
the Gregorian year values are used. Unlike
GregorianCalendar, the Julian to Gregorian transition is not
supported because it doesn't make any sense to the Japanese
calendar systems used before Meiji. To represent the years before
Gregorian year 1, 0 and negative values are used. The Japanese
Imperial rescripts and government decrees don't specify how to deal
with time differences for applying the era transitions. This
calendar implementation assumes local time for all transitions.
A new era can be specified using property jdk.calendar.japanese.supplemental.era. The new era is added to the predefined eras. The syntax of the property is as follows.
name=<name>,abbr=<abbr>,since=<time['u']>
where
<name>:\\uXXXX)
<abbr>:\\uXXXX)
<time['u']>:'u' is
appended to the milliseconds value. (ASCII digits only)
If the given era is invalid, such as the since value before the beginning of the last predefined era, the given era will be ignored.
The following is an example of the property usage.
java -Djdk.calendar.japanese.supplemental.era="name=NewEra,abbr=N,since=253374307200000"The property specifies an era change to NewEra at 9999-02-11T00:00:00 local time.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | BEFORE_MEIJI
The ERA constant designating the era before Meiji. |
| private static final Era | |
| private transient long | cachedFixedDate
The fixed date corresponding to jdate. |
| private static final int | |
| private static final int | |
| private static final Era[] | |
| private static final Gregorian | |
| public static final int | HEISEI
The ERA constant designating the Heisei era. |
| private static final LocalGregorianCalendar | |
| private transient LocalGregorianCalendar. | jdate
jdate always has a sun.util.calendar.LocalGregorianCalendar.Date instance to avoid overhead of creating it for each calculation. |
| pack-priv static final int[] | |
| pack-priv static final int[] | |
| public static final int | MEIJI
The ERA constant designating the Meiji era. |
| pack-priv static final int[] | |
| private static final long | |
| private static final int | |
| private static final int | |
| private static final int | |
| private transient int[] | originalFields
Temporary storage for saving original fields[] values in non-lenient mode. |
| private static final int | REIWA
The ERA constant designating the Reiwa era. |
| private static final long | |
| public static final int | SHOWA
The ERA constant designating the Showa era. |
| private static final long[] | |
| public static final int | TAISHO
The ERA constant designating the Taisho era. |
| private transient int[] | zoneOffsets
Temporary int[2] to get time zone offsets. |
| Access | Constructor and Description |
|---|---|
| pack-priv | JapaneseImperialCalendar(TimeZone
the given time zone. zone, Locale the given locale. aLocale)Constructs a |
| pack-priv | JapaneseImperialCalendar(TimeZone
the given time zone zone, Locale the given locale aLocale, boolean the flag requesting an empty instance flag)Constructs an "empty" |
| Modifier and Type | Method and Description |
|---|---|
| private int | |
| public void | add(int
the calendar field. field, int the amount of date or time to be added to the field. amount)Implements abstract java. Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules. |
| public Object | |
| protected void | computeFields()
Implements abstract java. Converts the time value (millisecond offset from the Epoch) to calendar field values. |
| private int | Returns: a new field mask that indicates what field values have actually been set.a bit mask to specify which fields to change
the setting state. fieldMask, int a bit mask to specify which time zone offset
fields to be used for time calculations tzMask)This computeFields implements the conversion from UTC (millisecond offset from the Epoch) to calendar field values. |
| protected void | computeTime()
Implements abstract java. Converts calendar field values to the time value (millisecond offset from the Epoch). |
| public boolean | Returns: true if this object is equal to obj;
false otherwise.the object to compare with. obj)Overrides java. Compares this |
| public int | Returns: the maximum of the given field for the time value of thisJapaneseImperialCalendarthe calendar field field)Overrides java. Returns the maximum value that this calendar field could have,
taking into consideration the given time value and the current
values of the
|
| public int | Returns: the minimum of the given field for the time value of thisJapaneseImperialCalendarthe calendar field field)Overrides java. Returns the minimum value that this calendar field could have,
taking into consideration the given time value and the current
values of the
|
| private static LocalGregorianCalendar. | getCalendarDate(long
the fixed date fd)Returns a LocalGregorianCalendar.Date produced from the specified fixed date. |
| public String | Returns: "japanese"Overrides java. Returns |
| public String | getDisplayName(int field, int style, Locale locale)
Overrides java. Returns the string representation of the calendar
|
| public Map | getDisplayNames(int field, int style, Locale locale)
Overrides java. Returns a |
| private static int | |
| private long | Returns: the fixed dateera index era, int the normalized year number, with 0 indicating the
year 1 BCE, -1 indicating 2 BCE, etc. year, int the calendar fields to be used for the date calculation fieldMask)Computes the fixed date under either the Gregorian or the Julian calendar, using the given year and the specified calendar fields. |
| private long | getFixedDateJan1(LocalGregorianCalendar.
the date for which the first day of the year is
calculated. The date has to be in the cut-over year. date,the fixed date representation of the date fixedDate)Returns the fixed date of the first day of the year (usually January 1) before the specified date. |
| private long | getFixedDateMonth1(LocalGregorianCalendar.
the date for which the first day of the month is
calculated. The date must be in the era transition year. date,the fixed date representation of the date fixedDate)Returns the fixed date of the first date of the month (usually the 1st of the month) before the specified date. |
| public int | Returns: the highest minimum value for the given calendar field.the calendar field. field)Implements abstract java. Returns the highest minimum value for the given calendar field
of this |
| public int | Returns: the lowest maximum value for the given calendar field.the calendar field field)Implements abstract java. Returns the lowest maximum value for the given calendar field
of this |
| public int | Returns: the maximum value for the given calendar field.the calendar field. field)Implements abstract java. Returns the maximum value for the given calendar field of this
|
| public int | Returns: the minimum value for the given calendar field.the calendar field. field)Implements abstract java. Returns the minimum value for the given calendar field of this
|
| private JapaneseImperialCalendar | |
| private static int | getRolledValue(int value, int amount, int min, int max)
Returns the new value after 'roll'ing the specified value and amount. |
| public TimeZone | |
| private static int | getTransitionEraIndex(LocalGregorianCalendar.
Returns the index to the new era if the given date is in a transition month. |
| private int | Returns: the number of weeks of the given periodthe fixed date of the first day of the period fixedDay1, long the fixed date of the last day of the period fixedDate)Returns the number of weeks in a period between fixedDay1 and fixedDate. |
| private long | getYearOffsetInMillis(CalendarDate date)
Returns the millisecond offset from the beginning of the year. |
| public int | hashCode()
Overrides java. Generates the hash code for this
|
| private int | |
| private boolean | |
| private int | monthLength(int month, int gregorianYear)
Returns the length of the specified month in the specified Gregorian year. |
| private int | monthLength(int month)
Returns the length of the specified month in the year provided by internalGet(YEAR). |
| private void | pinDayOfMonth(LocalGregorianCalendar.
After adjustments such as add(MONTH), add(YEAR), we don't want the month to jump around. |
| private void | |
| public void | roll(int field, boolean up)
Implements abstract java. Adds or subtracts (up/down) a single unit of time on the given time field without changing larger fields. |
| public void | roll(int
the calendar field. field, int the signed amount to add to amount)field.Overrides java. Adds a signed amount to the specified calendar field without changing larger fields. |
| public void | setTimeZone(TimeZone zone)
Overrides java. Sets the time zone with the given time zone value. |
| BEFORE_MEIJI | back to summary |
|---|---|
| public static final int BEFORE_MEIJI The ERA constant designating the era before Meiji. | |
| BEFORE_MEIJI_ERA | back to summary |
|---|---|
| private static final Era BEFORE_MEIJI_ERA | |
| cachedFixedDate | back to summary |
|---|---|
| private transient long cachedFixedDate The fixed date corresponding to jdate. If the value is Long.MIN_VALUE, the fixed date value is unknown. | |
| currentEra | back to summary |
|---|---|
| private static final int currentEra | |
| EPOCH_OFFSET | back to summary |
|---|---|
| private static final int EPOCH_OFFSET | |
| eras | back to summary |
|---|---|
| private static final Era[] eras | |
| gcal | back to summary |
|---|---|
| private static final Gregorian gcal | |
| HEISEI | back to summary |
|---|---|
| public static final int HEISEI The ERA constant designating the Heisei era. | |
| jcal | back to summary |
|---|---|
| private static final LocalGregorianCalendar jcal | |
| jdate | back to summary |
|---|---|
| private transient LocalGregorianCalendar. jdate always has a sun.util.calendar.LocalGregorianCalendar.Date instance to avoid overhead of creating it for each calculation. | |
| LEAST_MAX_VALUES | back to summary |
|---|---|
| pack-priv static final int[] LEAST_MAX_VALUES | |
| MAX_VALUES | back to summary |
|---|---|
| pack-priv static final int[] MAX_VALUES | |
| MEIJI | back to summary |
|---|---|
| public static final int MEIJI The ERA constant designating the Meiji era. | |
| MIN_VALUES | back to summary |
|---|---|
| pack-priv static final int[] MIN_VALUES | |
| ONE_DAY | back to summary |
|---|---|
| private static final long ONE_DAY | |
| ONE_HOUR | back to summary |
|---|---|
| private static final int ONE_HOUR | |
| ONE_MINUTE | back to summary |
|---|---|
| private static final int ONE_MINUTE | |
| ONE_SECOND | back to summary |
|---|---|
| private static final int ONE_SECOND | |
| originalFields | back to summary |
|---|---|
| private transient int[] originalFields Temporary storage for saving original fields[] values in non-lenient mode. | |
| REIWA | back to summary |
|---|---|
| private static final int REIWA The ERA constant designating the Reiwa era. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java.
| |
| SHOWA | back to summary |
|---|---|
| public static final int SHOWA The ERA constant designating the Showa era. | |
| sinceFixedDates | back to summary |
|---|---|
| private static final long[] sinceFixedDates | |
| TAISHO | back to summary |
|---|---|
| public static final int TAISHO The ERA constant designating the Taisho era. | |
| zoneOffsets | back to summary |
|---|---|
| private transient int[] zoneOffsets Temporary int[2] to get time zone offsets. zoneOffsets[0] gets the GMT offset value and zoneOffsets[1] gets the daylight saving value. | |
| JapaneseImperialCalendar | back to summary |
|---|---|
| pack-priv JapaneseImperialCalendar(TimeZone zone, Locale aLocale) Constructs a | |
| JapaneseImperialCalendar | back to summary |
|---|---|
| pack-priv JapaneseImperialCalendar(TimeZone zone, Locale aLocale, boolean flag) Constructs an "empty" | |
| actualMonthLength | back to summary |
|---|---|
| private int actualMonthLength() | |
| add | back to summary |
|---|---|
| public void add(int field, int amount) Implements abstract java. Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules. Add rule 1. The value of Add rule 2. If a smaller field is expected to be
invariant, but it is impossible for it to be equal to its
prior value because of changes in its minimum or maximum after
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Doc from java. Creates and returns a copy of this object. | |
| computeFields | back to summary |
|---|---|
| protected void computeFields() Implements abstract java. Converts the time value (millisecond offset from the Epoch) to calendar field values.
The time is not
recomputed first; to recompute the time, then the fields, call the
| |
| computeFields | back to summary |
|---|---|
| private int computeFields(int fieldMask, int tzMask) This computeFields implements the conversion from UTC (millisecond offset from the Epoch) to calendar field values. fieldMask specifies which fields to change the setting state to COMPUTED, although all fields are set to the correct values. This is required to fix 4685354.
| |
| computeTime | back to summary |
|---|---|
| protected void computeTime() Implements abstract java. Converts calendar field values to the time value (millisecond offset from the Epoch).
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Compares this
| |
| getActualMaximum | back to summary |
|---|---|
| public int getActualMaximum(int field) Overrides java. Returns the maximum value that this calendar field could have,
taking into consideration the given time value and the current
values of the
| |
| getActualMinimum | back to summary |
|---|---|
| public int getActualMinimum(int field) Overrides java. Returns the minimum value that this calendar field could have,
taking into consideration the given time value and the current
values of the
| |
| getCalendarDate | back to summary |
|---|---|
| private static LocalGregorianCalendar. Returns a LocalGregorianCalendar.Date produced from the specified fixed date.
| |
| getCalendarType | back to summary |
|---|---|
| public String getCalendarType() Overrides java. Returns | |
| getDisplayName | back to summary |
|---|---|
| public String getDisplayName(int field, int style, Locale locale) Overrides java. Doc from java. Returns the string representation of the calendar
For example, if this The default implementation supports the calendar fields for
which a If there is no string representation of the
| |
| getDisplayNames | back to summary |
|---|---|
| public Map Overrides java. Doc from java. Returns a Narrow names may not be unique due to use of single characters,
such as "S" for Sunday and Saturday. In that case narrow names are not
included in the returned The values of other calendar fields may be taken into
account to determine a set of display names. For example, if
this The default implementation supports display names contained in
a Unlike
| |
| getEraIndex | back to summary |
|---|---|
| private static int getEraIndex(LocalGregorianCalendar. | |
| getFixedDate | back to summary |
|---|---|
| private long getFixedDate(int era, int year, int fieldMask) Computes the fixed date under either the Gregorian or the Julian calendar, using the given year and the specified calendar fields.
| |
| getFixedDateJan1 | back to summary |
|---|---|
| private long getFixedDateJan1(LocalGregorianCalendar. Returns the fixed date of the first day of the year (usually January 1) before the specified date.
| |
| getFixedDateMonth1 | back to summary |
|---|---|
| private long getFixedDateMonth1(LocalGregorianCalendar. Returns the fixed date of the first date of the month (usually the 1st of the month) before the specified date.
| |
| getGreatestMinimum | back to summary |
|---|---|
| public int getGreatestMinimum(int field) Implements abstract java. Returns the highest minimum value for the given calendar field
of this
| |
| getLeastMaximum | back to summary |
|---|---|
| public int getLeastMaximum(int field) Implements abstract java. Returns the lowest maximum value for the given calendar field
of this
| |
| getMaximum | back to summary |
|---|---|
| public int getMaximum(int field) Implements abstract java. Returns the maximum value for the given calendar field of this
| |
| getMinimum | back to summary |
|---|---|
| public int getMinimum(int field) Implements abstract java. Returns the minimum value for the given calendar field of this
| |
| getNormalizedCalendar | back to summary |
|---|---|
| private JapaneseImperialCalendar getNormalizedCalendar() Returns this object if it's normalized (all fields and time are in sync). Otherwise, a cloned object is returned after calling complete() in lenient mode. | |
| getRolledValue | back to summary |
|---|---|
| private static int getRolledValue(int value, int amount, int min, int max) Returns the new value after 'roll'ing the specified value and amount. | |
| getTimeZone | back to summary |
|---|---|
| public TimeZone getTimeZone() Overrides java. Doc from java. Gets the time zone. | |
| getTransitionEraIndex | back to summary |
|---|---|
| private static int getTransitionEraIndex(LocalGregorianCalendar. Returns the index to the new era if the given date is in a transition month. For example, if the give date is Heisei 1 (1989) January 20, then the era index for Heisei is returned. Likewise, if the given date is Showa 64 (1989) January 3, then the era index for Heisei is returned. If the given date is not in any transition month, then -1 is returned. | |
| getWeekNumber | back to summary |
|---|---|
| private int getWeekNumber(long fixedDay1, long fixedDate) Returns the number of weeks in a period between fixedDay1 and fixedDate. The getFirstDayOfWeek-getMinimalDaysInFirstWeek rule is applied to calculate the number of weeks.
| |
| getYearOffsetInMillis | back to summary |
|---|---|
| private long getYearOffsetInMillis(CalendarDate date) Returns the millisecond offset from the beginning of the year. In the year for Long.MIN_VALUE, it's a pseudo value beyond the limit. The given CalendarDate object must have been normalized before calling this method. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Generates the hash code for this
| |
| internalGetEra | back to summary |
|---|---|
| private int internalGetEra() Returns the ERA. We need a special method for this because the default ERA is the current era, but a zero (unset) ERA means before Meiji. | |
| isTransitionYear | back to summary |
|---|---|
| private boolean isTransitionYear(int normalizedYear) | |
| monthLength | back to summary |
|---|---|
| private int monthLength(int month, int gregorianYear) Returns the length of the specified month in the specified Gregorian year. The year number must be normalized.
| |
| monthLength | back to summary |
|---|---|
| private int monthLength(int month) Returns the length of the specified month in the year provided by internalGet(YEAR).
| |
| pinDayOfMonth | back to summary |
|---|---|
| private void pinDayOfMonth(LocalGregorianCalendar. After adjustments such as add(MONTH), add(YEAR), we don't want the month to jump around. E.g., we don't want Jan 31 + 1 month to go to Mar 3, we want it to go to Feb 28. Adjustments which might run into this problem call this method to retain the proper month. | |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException Hides java. Updates internal state.
| |
| roll | back to summary |
|---|---|
| public void roll(int field, boolean up) Implements abstract java. Doc from java. Adds or subtracts (up/down) a single unit of time on the given time field without changing larger fields. For example, to roll the current date up by one day, you can achieve it by calling: roll(Calendar.DATE, true).
When rolling on the year or Calendar.YEAR field, it will roll the year
value in the range between 1 and the value returned by calling
| |
| roll | back to summary |
|---|---|
| public void roll(int field, int amount) Overrides java. Adds a signed amount to the specified calendar field without changing larger fields. A negative roll amount means to subtract from field without changing larger fields. If the specified amount is 0, this method performs nothing. This method calls
| |
| setTimeZone | back to summary |
|---|---|
| public void setTimeZone(TimeZone zone) Overrides java. Doc from java. Sets the time zone with the given time zone value. | |