public class JapaneseCalendar extends GregorianCalendar
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
Calendar.getInstance(ULocale)
passing in a ULocale
with the tag "@calendar=japanese"
.
GregorianCalendar
,
Calendar
,
Serialized FormCalendar.FormatConfiguration, Calendar.WeekData
Modifier and Type | Field and Description |
---|---|
static int |
CURRENT_ERA |
static int |
HEISEI
Constant for the era starting on Jan. 7, 1989 AD.
|
static int |
MEIJI
Constant for the era starting on Sept. 8, 1868 AD.
|
static int |
REIWA
Constant for the era starting on May 1, 2019 AD.
|
static int |
SHOWA
Constant for the era starting on Dec. 25, 1926 AD.
|
static int |
TAISHO
Constant for the era starting on July 30, 1912 AD.
|
AD, BC, invertGregorian, isGregorian
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, IS_LEAP_MONTH, 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, ORDINAL_MONTH, PM, RESOLVE_REMAP, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, UNSET, WALLTIME_FIRST, WALLTIME_LAST, WALLTIME_NEXT_VALID, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, WEEKDAY, WEEKEND, WEEKEND_CEASE, WEEKEND_ONSET, YEAR, YEAR_WOY, ZONE_OFFSET
Constructor and Description |
---|
JapaneseCalendar()
Constructs a default
JapaneseCalendar using the current time
in the default time zone with the default locale. |
JapaneseCalendar(Date date)
Constructs a
JapaneseCalendar with the given date set
in the default time zone with the default locale. |
JapaneseCalendar(int year,
int month,
int date)
Constructs a
JapaneseCalendar with the given date set
in the default time zone with the default locale. |
JapaneseCalendar(int era,
int year,
int month,
int date)
Constructs a
JapaneseCalendar with the given date set
in the default time zone with the default locale. |
JapaneseCalendar(int year,
int month,
int date,
int hour,
int minute,
int second)
Constructs a
JapaneseCalendar with the given date
and time set for the default time zone with the default locale. |
JapaneseCalendar(Locale aLocale)
Constructs a
JapaneseCalendar based on the current time
in the default time zone with the given locale. |
JapaneseCalendar(TimeZone zone)
Constructs a
JapaneseCalendar based on the current time
in the given time zone with the default locale. |
JapaneseCalendar(TimeZone zone,
Locale aLocale)
Constructs a
JapaneseCalendar based on the current time
in the given time zone with the given locale. |
JapaneseCalendar(TimeZone zone,
ULocale locale)
Constructs a
JapaneseCalendar based on the current time
in the given time zone with the given locale. |
JapaneseCalendar(ULocale locale)
Constructs a
JapaneseCalendar based on the current time
in the default time zone with the given locale. |
Modifier and Type | Method and Description |
---|---|
static boolean |
enableTentativeEra()
Deprecated.
This API is ICU internal only.
|
int |
getActualMaximum(int field)
Return the maximum value that this field could have, given the current date.
|
protected int |
getDefaultDayInMonth(int extendedYear,
int month)
Called by handleComputeJulianDay.
|
protected int |
getDefaultMonthInYear(int extendedYear)
Called by handleComputeJulianDay.
|
String |
getType()
[icu] Returns the calendar type name string for this Calendar object.
|
protected void |
handleComputeFields(int julianDay)
Override Calendar to compute several fields specific to the hybrid
Gregorian-Julian calendar system.
|
protected int |
handleGetExtendedYear()
Returns the extended year defined by the current fields.
|
protected int |
handleGetLimit(int field,
int limitType)
Override GregorianCalendar.
|
boolean |
haveDefaultCentury()
Deprecated.
This API is ICU internal only.
|
protected boolean |
isEra0CountingBackward()
Deprecated.
This API is ICU internal only.
|
getActualMinimum, getGregorianChange, handleComputeJulianDay, handleComputeMonthStart, handleGetMonthLength, handleGetYearLength, hashCode, isEquivalentTo, isLeapYear, roll, setGregorianChange
add, after, before, clear, clear, clone, compareTo, complete, computeFields, computeGregorianFields, computeGregorianMonthStart, computeJulianDay, computeMillisInDay, computeMillisInDayLong, computeTime, computeZoneOffset, computeZoneOffset, equals, fieldDifference, fieldName, floorDivide, floorDivide, floorDivide, floorDivide, get, getAvailableLocales, getAvailableULocales, getDateAtTimePattern, getDateTimeFormat, getDateTimeFormat, getDateTimePattern, getDayOfWeekType, getDisplayName, getDisplayName, getFieldCount, getFieldResolutionTable, getFirstDayOfWeek, getGreatestMinimum, getGregorianDayOfMonth, getGregorianDayOfYear, getGregorianMonth, getGregorianYear, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getKeywordValuesForLocale, getLeastMaximum, getLimit, getLocale, getMaximum, getMinimalDaysInFirstWeek, getMinimum, getRelatedYear, getRepeatedWallTimeOption, getSkippedWallTimeOption, getStamp, getTemporalMonthCode, getTime, getTimeInMillis, getTimeZone, getWeekData, getWeekDataForRegion, getWeekendTransition, gregorianMonthLength, gregorianPreviousMonthLength, handleCreateFields, handleGetDateFormat, handleGetDateFormat, handleGetDateFormat, handleGetDateFormat, inTemporalLeapYear, internalGet, internalGet, internalGetMonth, internalGetMonth, internalGetTimeInMillis, internalSet, isGregorianLeapYear, isLenient, isSet, isWeekend, isWeekend, julianDayToDayOfWeek, julianDayToMillis, millisToJulianDay, newerField, newestStamp, pinField, prepareGetActual, resolveFields, roll, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setRelatedYear, setRepeatedWallTimeOption, setSkippedWallTimeOption, setTemporalMonthCode, setTime, setTimeInMillis, setTimeZone, setWeekData, toString, validateField, validateField, validateFields, weekNumber, weekNumber
public static final int CURRENT_ERA
public static final int MEIJI
public static final int TAISHO
public static final int SHOWA
public static final int HEISEI
public static final int REIWA
public JapaneseCalendar()
JapaneseCalendar
using the current time
in the default time zone with the default locale.public JapaneseCalendar(TimeZone zone)
JapaneseCalendar
based on the current time
in the given time zone with the default locale.zone
- the given time zone.public JapaneseCalendar(Locale aLocale)
JapaneseCalendar
based on the current time
in the default time zone with the given locale.aLocale
- the given locale.public JapaneseCalendar(ULocale locale)
JapaneseCalendar
based on the current time
in the default time zone with the given locale.locale
- the given ulocale.public JapaneseCalendar(TimeZone zone, Locale aLocale)
JapaneseCalendar
based on the current time
in the given time zone with the given locale.zone
- the given time zone.aLocale
- the given locale.public JapaneseCalendar(TimeZone zone, ULocale locale)
JapaneseCalendar
based on the current time
in the given time zone with the given locale.zone
- the given time zone.locale
- the given ulocale.public JapaneseCalendar(Date date)
JapaneseCalendar
with the given date set
in the default time zone with the default locale.date
- The date to which the new calendar is set.public JapaneseCalendar(int era, int year, int month, int date)
JapaneseCalendar
with the given date set
in the default time zone with the default locale.era
- The imperial era used to set the calendar's ERA
field.
Eras are numbered starting with the Tenki era, which
began in 1053 AD Gregorian, as era zero. Recent
eras can be specified using the constants
MEIJI
(which started in 1868 AD),
TAISHO
(1912 AD),
SHOWA
(1926 AD), and
HEISEI
(1989 AD).year
- The value used to set the calendar's YEAR
field,
in terms of the era.month
- The value used to set the calendar's MONTH
field.
The value is 0-based. e.g., 0 for January.date
- The value used to set the calendar's DATE field.public JapaneseCalendar(int year, int month, int date)
JapaneseCalendar
with the given date set
in the default time zone with the default locale.year
- The value used to set the calendar's YEAR
field,
in the era Heisei, the most current at the time this
class was last updated.month
- The value used to set the calendar's MONTH
field.
The value is 0-based. e.g., 0 for January.date
- The value used to set the calendar's DATE
field.public JapaneseCalendar(int year, int month, int date, int hour, int minute, int second)
JapaneseCalendar
with the given date
and time set for the default time zone with the default locale.year
- The value used to set the calendar's YEAR
time field,
in the era Heisei, the most current at the time of this
writing.month
- The value used to set the calendar's MONTH
time field.
The value is 0-based. e.g., 0 for January.date
- The value used to set the calendar's DATE
time field.hour
- The value used to set the calendar's HOUR_OF_DAY
time field.minute
- The value used to set the calendar's MINUTE
time field.second
- The value used to set the calendar's SECOND
time field.@Deprecated public static boolean enableTentativeEra()
protected int handleGetExtendedYear()
Calendar
handleGetExtendedYear
in class GregorianCalendar
protected int getDefaultMonthInYear(int extendedYear)
getDefaultMonthInYear
in class Calendar
extendedYear
- the extendedYear, as returned by handleGetExtendedYearCalendar.MONTH
protected int getDefaultDayInMonth(int extendedYear, int month)
getDefaultDayInMonth
in class Calendar
extendedYear
- the extendedYear, as returned by handleGetExtendedYearmonth
- the month, as returned by getDefaultMonthInYearCalendar.DAY_OF_MONTH
protected void handleComputeFields(int julianDay)
GregorianCalendar
handleComputeFields
in class GregorianCalendar
protected int handleGetLimit(int field, int limitType)
handleGetLimit
in class GregorianCalendar
field
- one of the above field numberslimitType
- one of MINIMUM
, GREATEST_MINIMUM
,
LEAST_MAXIMUM
, or MAXIMUM
public String getType()
See type="old type name" for the calendar attribute of locale IDs at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
getType
in class GregorianCalendar
@Deprecated public boolean haveDefaultCentury()
true
. A subclass may
return false
if such practice is not applicable (for example,
Chinese calendar and Japanese calendar).haveDefaultCentury
in class Calendar
true
if this calendar has a default century.public int getActualMaximum(int field)
getActualMaximum
in class GregorianCalendar
field
- the field whose maximum is desiredCalendar.getMaximum(int)
,
Calendar.getLeastMaximum(int)
@Deprecated protected boolean isEra0CountingBackward()
isEra0CountingBackward
in class GregorianCalendar
Copyright © 2016 Unicode, Inc. and others.