APIdia Launch Partner
Top Description Fields Constructors Methods
java.util

pack-priv Class JapaneseImperialCalendar

extends Calendar
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, sun.util.locale.provider.CalendarDataUtility, sun.util.calendar.BaseCalendar, .CalendarDate, .CalendarSystem, .CalendarUtils, .Era, .Gregorian, .LocalGregorianCalendar, .ZoneInfo

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>:
the full name of the new era (non-ASCII characters allowed, either in platform's native encoding or in Unicode escape notation, \\uXXXX)
<abbr>:
the abbreviation of the new era (non-ASCII characters allowed, either in platform's native encoding or in Unicode escape notation, \\uXXXX)
<time['u']>:
the start time of the new era represented by milliseconds from 1970-01-01T00:00:00 local time or UTC if '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.
Author
Masayoshi Okutsu
Since
1.6

Field Summary

Modifier and TypeField 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.Date
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.

Inherited from java.util.Calendar:
ALL_FIELDSALL_STYLESAMAM_PMAM_PM_MASKAPRILareAllFieldsSetareFieldsSetAUGUSTcurrentSerialVersionDATEDAY_OF_MONTHDAY_OF_MONTH_MASKDAY_OF_WEEKDAY_OF_WEEK_IN_MONTHDAY_OF_WEEK_IN_MONTH_MASKDAY_OF_WEEK_MASKDAY_OF_YEARDAY_OF_YEAR_MASKDECEMBERDST_OFFSETDST_OFFSET_MASKERAERA_MASKFEBRUARYFIELD_COUNTfieldsFRIDAYHOURHOUR_MASKHOUR_OF_DAYHOUR_OF_DAY_MASKisSetisTimeSetJANUARYJULYJUNELONGLONG_FORMATLONG_STANDALONEMARCHMAYMILLISECONDMILLISECOND_MASKMINUTEMINUTE_MASKMONDAYMONTHMONTH_MASKNARROW_FORMATNARROW_STANDALONENOVEMBEROCTOBERPMSATURDAYSECONDSECOND_MASKSEPTEMBERSHORTSHORT_FORMATSHORT_STANDALONESTANDALONE_MASKSUNDAYTHURSDAYtimeTUESDAYUNDECIMBERWEDNESDAYWEEK_OF_MONTHWEEK_OF_MONTH_MASKWEEK_OF_YEARWEEK_OF_YEAR_MASKYEARYEAR_MASKZONE_OFFSETZONE_OFFSET_MASK

Constructor Summary

AccessConstructor and Description
pack-priv
JapaneseImperialCalendar(TimeZone
the given time zone.
zone
,
Locale
the given locale.
aLocale
)

Constructs a JapaneseImperialCalendar based on the current time in the given time zone with the given locale.

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" JapaneseImperialCalendar.

Method Summary

Modifier and TypeMethod 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.util.Calendar.add.

Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

public Object
clone()

Overrides java.util.Calendar.clone.

Creates and returns a copy of this object.

protected void
computeFields()

Implements abstract java.util.Calendar.computeFields.

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.
computeFields
(int
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.util.Calendar.computeTime.

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.
equals
(Object
the object to compare with.
obj
)

Overrides java.util.Calendar.equals.

Compares this JapaneseImperialCalendar to the specified Object.

public int

Returns:

the maximum of the given field for the time value of this JapaneseImperialCalendar
getActualMaximum
(int
the calendar field
field
)

Overrides java.util.Calendar.getActualMaximum.

Returns the maximum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods.

public int

Returns:

the minimum of the given field for the time value of this JapaneseImperialCalendar
getActualMinimum
(int
the calendar field
field
)

Overrides java.util.Calendar.getActualMinimum.

Returns the minimum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods.

private static LocalGregorianCalendar.Date
getCalendarDate(long
the fixed date
fd
)

Returns a LocalGregorianCalendar.Date produced from the specified fixed date.

public String

Returns:

"japanese"
getCalendarType
()

Overrides java.util.Calendar.getCalendarType.

Returns "japanese" as the calendar type of this JapaneseImperialCalendar.

public String
getDisplayName(int field, int style, Locale locale)

Overrides java.util.Calendar.getDisplayName.

Returns the string representation of the calendar field value in the given style and locale.

public Map<String, Integer>
getDisplayNames(int field, int style, Locale locale)

Overrides java.util.Calendar.getDisplayNames.

Returns a Map containing all names of the calendar field in the given style and locale and their corresponding field values.

private static int
private long

Returns:

the fixed date
getFixedDate
(int
era 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.Date
the date for which the first day of the year is calculated. The date has to be in the cut-over year.
date
,
long
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.Date
the date for which the first day of the month is calculated. The date must be in the era transition year.
date
,
long
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.
getGreatestMinimum
(int
the calendar field.
field
)

Implements abstract java.util.Calendar.getGreatestMinimum.

Returns the highest minimum value for the given calendar field of this GregorianCalendar instance.

public int

Returns:

the lowest maximum value for the given calendar field.
getLeastMaximum
(int
the calendar field
field
)

Implements abstract java.util.Calendar.getLeastMaximum.

Returns the lowest maximum value for the given calendar field of this GregorianCalendar instance.

public int

Returns:

the maximum value for the given calendar field.
getMaximum
(int
the calendar field.
field
)

Implements abstract java.util.Calendar.getMaximum.

Returns the maximum value for the given calendar field of this GregorianCalendar instance.

public int

Returns:

the minimum value for the given calendar field.
getMinimum
(int
the calendar field.
field
)

Implements abstract java.util.Calendar.getMinimum.

Returns the minimum value for the given calendar field of this Calendar instance.

private JapaneseImperialCalendar
getNormalizedCalendar()

Returns this object if it's normalized (all fields and time are in sync).

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
getTimeZone()

Overrides java.util.Calendar.getTimeZone.

Gets the time zone.

private static int
getTransitionEraIndex(LocalGregorianCalendar.Date date)

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 period
getWeekNumber
(long
the 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.util.Calendar.hashCode.

Generates the hash code for this JapaneseImperialCalendar object.

private int
internalGetEra()

Returns the ERA.

private boolean
isTransitionYear(int normalizedYear)

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.Date date)

After adjustments such as add(MONTH), add(YEAR), we don't want the month to jump around.

private void
readObject(ObjectInputStream stream)

Hides java.util.Calendar.readObject.

Updates internal state.

public void
roll(int field, boolean up)

Implements abstract java.util.Calendar.roll.

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 field.
amount
)

Overrides java.util.Calendar.roll.

Adds a signed amount to the specified calendar field without changing larger fields.

public void
setTimeZone(TimeZone zone)

Overrides java.util.Calendar.setTimeZone.

Sets the time zone with the given time zone value.

Inherited from java.util.Calendar:
afterbeforecheckDisplayNameParamsclearclearcompareTocompletegetgetAvailableCalendarTypesgetAvailableLocalesgetBaseStylegetFieldNamegetFirstDayOfWeekgetInstancegetInstancegetInstancegetInstancegetMinimalDaysInFirstWeekgetSetStateFieldsgetTimegetTimeInMillisgetWeeksInWeekYeargetWeekYeargetZoneinternalGetinternalSetisExternallySetisFieldSetisFullyNormalizedisLenientisPartiallyNormalizedisSetisWeekDateSupportedselectFieldssetsetsetsetsetFieldsComputedsetFieldsNormalizedsetFirstDayOfWeeksetLenientsetMinimalDaysInFirstWeeksetTimesetTimeInMillissetUnnormalizedsetWeekDatesetZoneSharedtoInstanttoString

Field Detail

BEFORE_MEIJIback to summary
public static final int BEFORE_MEIJI

The ERA constant designating the era before Meiji.

BEFORE_MEIJI_ERAback to summary
private static final Era BEFORE_MEIJI_ERA
cachedFixedDateback 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.

currentEraback to summary
private static final int currentEra
EPOCH_OFFSETback to summary
private static final int EPOCH_OFFSET
erasback to summary
private static final Era[] eras
gcalback to summary
private static final Gregorian gcal
HEISEIback to summary
public static final int HEISEI

The ERA constant designating the Heisei era.

jcalback to summary
private static final LocalGregorianCalendar jcal
jdateback to summary
private transient LocalGregorianCalendar.Date jdate

jdate always has a sun.util.calendar.LocalGregorianCalendar.Date instance to avoid overhead of creating it for each calculation.

LEAST_MAX_VALUESback to summary
pack-priv static final int[] LEAST_MAX_VALUES
MAX_VALUESback to summary
pack-priv static final int[] MAX_VALUES
MEIJIback to summary
public static final int MEIJI

The ERA constant designating the Meiji era.

MIN_VALUESback to summary
pack-priv static final int[] MIN_VALUES
ONE_DAYback to summary
private static final long ONE_DAY
ONE_HOURback to summary
private static final int ONE_HOUR
ONE_MINUTEback to summary
private static final int ONE_MINUTE
ONE_SECONDback to summary
private static final int ONE_SECOND
originalFieldsback to summary
private transient int[] originalFields

Temporary storage for saving original fields[] values in non-lenient mode.

REIWAback to summary
private static final int REIWA

The ERA constant designating the Reiwa era.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.Calendar.serialVersionUID.

Annotations
@SuppressWarnings:FieldNameHidesFieldInSuperclass
@Serial
SHOWAback to summary
public static final int SHOWA

The ERA constant designating the Showa era.

sinceFixedDatesback to summary
private static final long[] sinceFixedDates
TAISHOback to summary
public static final int TAISHO

The ERA constant designating the Taisho era.

zoneOffsetsback 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.

Constructor Detail

JapaneseImperialCalendarback to summary
pack-priv JapaneseImperialCalendar(TimeZone zone, Locale aLocale)

Constructs a JapaneseImperialCalendar based on the current time in the given time zone with the given locale.

Parameters
zone:TimeZone

the given time zone.

aLocale:Locale

the given locale.

JapaneseImperialCalendarback to summary
pack-priv JapaneseImperialCalendar(TimeZone zone, Locale aLocale, boolean flag)

Constructs an "empty" JapaneseImperialCalendar.

Parameters
zone:TimeZone

the given time zone

aLocale:Locale

the given locale

flag:boolean

the flag requesting an empty instance

Method Detail

actualMonthLengthback to summary
private int actualMonthLength()
addback to summary
public void add(int field, int amount)

Implements abstract java.util.Calendar.add.

Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

Add rule 1. The value of field after the call minus the value of field before the call is amount, modulo any overflow that has occurred in field. Overflow occurs when a field value exceeds its range and, as a result, the next larger field is incremented or decremented and the field value is adjusted back into its range.

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 field is changed, then its value is adjusted to be as close as possible to its expected value. A smaller field represents a smaller unit of time. HOUR is a smaller field than DAY_OF_MONTH. No adjustment is made to smaller fields that are not expected to be invariant. The calendar system determines what fields are expected to be invariant.

Parameters
field:int

the calendar field.

amount:int

the amount of date or time to be added to the field.

Annotations
@Override
Exceptions
IllegalArgumentException:
if field is ZONE_OFFSET, DST_OFFSET, or unknown, or if any calendar fields have out-of-range values in non-lenient mode.
cloneback to summary
public Object clone()

Overrides java.util.Calendar.clone.

Doc from java.util.Calendar.clone.

Creates and returns a copy of this object.

computeFieldsback to summary
protected void computeFields()

Implements abstract java.util.Calendar.computeFields.

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 complete method.

See Also
Calendar#complete
computeFieldsback 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.

Parameters
fieldMask:int

a bit mask to specify which fields to change the setting state.

tzMask:int

a bit mask to specify which time zone offset fields to be used for time calculations

Returns:int

a new field mask that indicates what field values have actually been set.

computeTimeback to summary
protected void computeTime()

Implements abstract java.util.Calendar.computeTime.

Converts calendar field values to the time value (millisecond offset from the Epoch).

Exceptions
IllegalArgumentException:
if any calendar fields are invalid.
equalsback to summary
public boolean equals(Object obj)

Overrides java.util.Calendar.equals.

Compares this JapaneseImperialCalendar to the specified Object. The result is true if and only if the argument is a JapaneseImperialCalendar object that represents the same time value (millisecond offset from the Epoch) under the same Calendar parameters.

Parameters
obj:Object

the object to compare with.

Returns:boolean

true if this object is equal to obj; false otherwise.

Annotations
@Override
See Also
Calendar#compareTo(Calendar)
getActualMaximumback to summary
public int getActualMaximum(int field)

Overrides java.util.Calendar.getActualMaximum.

Returns the maximum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods. For example, if the date of this instance is Heisei 16February 1, the actual maximum value of the DAY_OF_MONTH field is 29 because Heisei 16 is a leap year, and if the date of this instance is Heisei 17 February 1, it's 28.

Parameters
field:int

the calendar field

Returns:int

the maximum of the given field for the time value of this JapaneseImperialCalendar

See Also
getMinimum(int), getMaximum(int), getGreatestMinimum(int), getLeastMaximum(int), getActualMinimum(int)
getActualMinimumback to summary
public int getActualMinimum(int field)

Overrides java.util.Calendar.getActualMinimum.

Returns the minimum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods.

Parameters
field:int

the calendar field

Returns:int

the minimum of the given field for the time value of this JapaneseImperialCalendar

See Also
getMinimum(int), getMaximum(int), getGreatestMinimum(int), getLeastMaximum(int), getActualMaximum(int)
getCalendarDateback to summary
private static LocalGregorianCalendar.Date getCalendarDate(long fd)

Returns a LocalGregorianCalendar.Date produced from the specified fixed date.

Parameters
fd:long

the fixed date

getCalendarTypeback to summary
public String getCalendarType()

Overrides java.util.Calendar.getCalendarType.

Returns "japanese" as the calendar type of this JapaneseImperialCalendar.

Returns:String

"japanese"

Annotations
@Override
getDisplayNameback to summary
public String getDisplayName(int field, int style, Locale locale)

Overrides java.util.Calendar.getDisplayName.

Doc from java.util.Calendar.getDisplayName.

Returns the string representation of the calendar field value in the given style and locale. If no string representation is applicable, null is returned. This method calls get(field) to get the calendar field value if the string representation is applicable to the given calendar field.

For example, if this Calendar is a GregorianCalendar and its date is 2005-01-01, then the string representation of the MONTH field would be "January" in the long style in an English locale or "Jan" in the short style. However, no string representation would be available for the DAY_OF_MONTH field, and this method would return null.

The default implementation supports the calendar fields for which a DateFormatSymbols has names in the given locale.

If there is no string representation of the Calendar field and the calendar is in non-lenient mode and any calendar fields have invalid values, null is returned. If there is a string representation of the Calendar field and the calendar is in non-lenient mode and any calendar fields have invalid values, IllegalArgumentException will be thrown.

Annotations
@Override
getDisplayNamesback to summary
public Map<String, Integer> getDisplayNames(int field, int style, Locale locale)

Overrides java.util.Calendar.getDisplayNames.

Doc from java.util.Calendar.getDisplayNames.

Returns a Map containing all names of the calendar field in the given style and locale and their corresponding field values. For example, if this Calendar is a GregorianCalendar, the returned map would contain "Jan" to JANUARY, "Feb" to FEBRUARY, and so on, in the short style in an English locale.

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 Map.

The values of other calendar fields may be taken into account to determine a set of display names. For example, if this Calendar is a lunisolar calendar system and the year value given by the YEAR field has a leap month, this method would return month names containing the leap month name, and month names are mapped to their values specific for the year.

The default implementation supports display names contained in a DateFormatSymbols. For example, if field is MONTH and style is ALL_STYLES, this method returns a Map containing all strings returned by DateFormatSymbols#getShortMonths() and DateFormatSymbols#getMonths().

Unlike getDisplayName(int, int, Locale), this method will not throw an IllegalArgumentException if the Calendar is non-lenient and any of the calendar fields have invalid values. Instead, this method will return either null or a Map.

Annotations
@Override
getEraIndexback to summary
private static int getEraIndex(LocalGregorianCalendar.Date date)
getFixedDateback 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.

Parameters
era:int

era index

year:int

the normalized year number, with 0 indicating the year 1 BCE, -1 indicating 2 BCE, etc.

fieldMask:int

the calendar fields to be used for the date calculation

Returns:long

the fixed date

See Also
Calendar#selectFields
getFixedDateJan1back to summary
private long getFixedDateJan1(LocalGregorianCalendar.Date date, long fixedDate)

Returns the fixed date of the first day of the year (usually January 1) before the specified date.

Parameters
date:LocalGregorianCalendar.Date

the date for which the first day of the year is calculated. The date has to be in the cut-over year.

fixedDate:long

the fixed date representation of the date

getFixedDateMonth1back to summary
private long getFixedDateMonth1(LocalGregorianCalendar.Date date, long fixedDate)

Returns the fixed date of the first date of the month (usually the 1st of the month) before the specified date.

Parameters
date:LocalGregorianCalendar.Date

the date for which the first day of the month is calculated. The date must be in the era transition year.

fixedDate:long

the fixed date representation of the date

getGreatestMinimumback to summary
public int getGreatestMinimum(int field)

Implements abstract java.util.Calendar.getGreatestMinimum.

Returns the highest minimum value for the given calendar field of this GregorianCalendar instance. The highest minimum value is defined as the largest value returned by getActualMinimum(int) for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods.

Parameters
field:int

the calendar field.

Returns:int

the highest minimum value for the given calendar field.

See Also
getMinimum(int), getMaximum(int), getLeastMaximum(int), getActualMinimum(int), getActualMaximum(int)
getLeastMaximumback to summary
public int getLeastMaximum(int field)

Implements abstract java.util.Calendar.getLeastMaximum.

Returns the lowest maximum value for the given calendar field of this GregorianCalendar instance. The lowest maximum value is defined as the smallest value returned by getActualMaximum(int) for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods.

Parameters
field:int

the calendar field

Returns:int

the lowest maximum value for the given calendar field.

See Also
getMinimum(int), getMaximum(int), getGreatestMinimum(int), getActualMinimum(int), getActualMaximum(int)
getMaximumback to summary
public int getMaximum(int field)

Implements abstract java.util.Calendar.getMaximum.

Returns the maximum value for the given calendar field of this GregorianCalendar instance. The maximum value is defined as the largest value returned by the get method for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods.

Parameters
field:int

the calendar field.

Returns:int

the maximum value for the given calendar field.

See Also
getMinimum(int), getGreatestMinimum(int), getLeastMaximum(int), getActualMinimum(int), getActualMaximum(int)
getMinimumback to summary
public int getMinimum(int field)

Implements abstract java.util.Calendar.getMinimum.

Returns the minimum value for the given calendar field of this Calendar instance. The minimum value is defined as the smallest value returned by the get method for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, and getTimeZone methods.

Parameters
field:int

the calendar field.

Returns:int

the minimum value for the given calendar field.

See Also
getMaximum(int), getGreatestMinimum(int), getLeastMaximum(int), getActualMinimum(int), getActualMaximum(int)
getNormalizedCalendarback 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.

getRolledValueback 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.

getTimeZoneback to summary
public TimeZone getTimeZone()

Overrides java.util.Calendar.getTimeZone.

Doc from java.util.Calendar.getTimeZone.

Gets the time zone.

getTransitionEraIndexback to summary
private static int getTransitionEraIndex(LocalGregorianCalendar.Date date)

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.

getWeekNumberback 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.

Parameters
fixedDay1:long

the fixed date of the first day of the period

fixedDate:long

the fixed date of the last day of the period

Returns:int

the number of weeks of the given period

getYearOffsetInMillisback 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.

hashCodeback to summary
public int hashCode()

Overrides java.util.Calendar.hashCode.

Generates the hash code for this JapaneseImperialCalendar object.

Annotations
@Override
internalGetEraback 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.

isTransitionYearback to summary
private boolean isTransitionYear(int normalizedYear)
monthLengthback 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.

See Also
GregorianCalendar#isLeapYear(int)
monthLengthback to summary
private int monthLength(int month)

Returns the length of the specified month in the year provided by internalGet(YEAR).

See Also
GregorianCalendar#isLeapYear(int)
pinDayOfMonthback to summary
private void pinDayOfMonth(LocalGregorianCalendar.Date date)

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.

readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException

Hides java.util.Calendar.readObject.

Updates internal state.

Annotations
@Serial
rollback to summary
public void roll(int field, boolean up)

Implements abstract java.util.Calendar.roll.

Doc from java.util.Calendar.roll.

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 getMaximum(Calendar.YEAR). When rolling on the month or Calendar.MONTH field, other fields like date might conflict and, need to be changed. For instance, rolling the month on the date 01/31/96 will result in 02/29/96. When rolling on the hour-in-day or Calendar.HOUR_OF_DAY field, it will roll the hour value in the range between 0 and 23, which is zero-based.

Annotations
@Override
rollback to summary
public void roll(int field, int amount)

Overrides java.util.Calendar.roll.

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 complete() before adding the amount so that all the calendar fields are normalized. If there is any calendar field having an out-of-range value in non-lenient mode, then an IllegalArgumentException is thrown.

Parameters
field:int

the calendar field.

amount:int

the signed amount to add to field.

Annotations
@Override
Exceptions
IllegalArgumentException:
if field is ZONE_OFFSET, DST_OFFSET, or unknown, or if any calendar fields have out-of-range values in non-lenient mode.
See Also
roll(int, boolean), add(int, int), set(int, int)
setTimeZoneback to summary
public void setTimeZone(TimeZone zone)

Overrides java.util.Calendar.setTimeZone.

Doc from java.util.Calendar.setTimeZone.

Sets the time zone with the given time zone value.