- java.lang.Object
-
- java.time.chrono.AbstractChronology
-
- java.time.chrono.JapaneseChronology
-
- All Implemented Interfaces:
Serializable,Comparable<Chronology>,Chronology
public final class JapaneseChronology extends AbstractChronology implements Serializable
The Japanese Imperial calendar system.This chronology defines the rules of the Japanese Imperial calendar system. This calendar system is primarily used in Japan. The Japanese Imperial calendar system is the same as the ISO calendar system apart from the era-based year numbering.
Japan introduced the Gregorian calendar starting with Meiji 6. Only Meiji and later eras are supported; dates before Meiji 6, January 1 are not supported.
The supported
ChronoFieldinstances are:DAY_OF_WEEKDAY_OF_MONTHDAY_OF_YEAREPOCH_DAYMONTH_OF_YEARPROLEPTIC_MONTHYEAR_OF_ERAYEARERA
- Implementation Requirements:
- This class is immutable and thread-safe.
- Since:
- 1.8
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static JapaneseChronologyINSTANCESingleton instance for Japanese chronology.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JapaneseDatedate(int prolepticYear, int month, int dayOfMonth)Obtains a local date in Japanese calendar system from the proleptic-year, month-of-year and day-of-month fields.JapaneseDatedate(Era era, int yearOfEra, int month, int dayOfMonth)Obtains a local date in Japanese calendar system from the era, year-of-era, month-of-year and day-of-month fields.JapaneseDatedateEpochDay(long epochDay)Obtains a local date in the Japanese calendar system from the epoch-day.JapaneseDatedateYearDay(int prolepticYear, int dayOfYear)Obtains a local date in Japanese calendar system from the proleptic-year and day-of-year fields.JapaneseDatedateYearDay(Era era, int yearOfEra, int dayOfYear)Obtains a local date in Japanese calendar system from the era, year-of-era and day-of-year fields.JapaneseEraeraOf(int eraValue)Returns the calendar system era object from the given numeric value.StringgetCalendarType()Gets the calendar type of the underlying calendar system - 'japanese'.StringgetId()Gets the ID of the chronology - 'Japanese'.booleanisLeapYear(long prolepticYear)Checks if the specified year is a leap year.-
Methods declared in class java.time.chrono.AbstractChronology
compareTo, equals, hashCode, resolveDate, toString
-
Methods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods declared in interface java.time.chrono.Chronology
date, dateNow, dateNow, dateNow, epochSecond, epochSecond, eras, getDisplayName, localDateTime, period, prolepticYear, range, zonedDateTime, zonedDateTime
-
-
-
-
Field Detail
-
INSTANCE
public static final JapaneseChronology INSTANCE
Singleton instance for Japanese chronology.
-
-
Method Detail
-
getId
public String getId()
Gets the ID of the chronology - 'Japanese'.The ID uniquely identifies the
Chronology. It can be used to lookup theChronologyusingChronology.of(String).- Specified by:
getIdin interfaceChronology- Returns:
- the chronology ID - 'Japanese'
- See Also:
getCalendarType()
-
getCalendarType
public String getCalendarType()
Gets the calendar type of the underlying calendar system - 'japanese'.The calendar type is an identifier defined by the Unicode Locale Data Markup Language (LDML) specification. It can be used to lookup the
ChronologyusingChronology.of(String). It can also be used as part of a locale, accessible viaLocale.getUnicodeLocaleType(String)with the key 'ca'.- Specified by:
getCalendarTypein interfaceChronology- Returns:
- the calendar system type - 'japanese'
- See Also:
getId()
-
date
public JapaneseDate date(Era era, int yearOfEra, int month, int dayOfMonth)
Obtains a local date in Japanese calendar system from the era, year-of-era, month-of-year and day-of-month fields.The Japanese month and day-of-month are the same as those in the ISO calendar system. They are not reset when the era changes. For example:
6th Jan Showa 64 = ISO 1989-01-06 7th Jan Showa 64 = ISO 1989-01-07 8th Jan Heisei 1 = ISO 1989-01-08 9th Jan Heisei 1 = ISO 1989-01-09
- Specified by:
datein interfaceChronology- Parameters:
era- the Japanese era, not nullyearOfEra- the year-of-eramonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Japanese local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aJapaneseEra
-
date
public JapaneseDate date(int prolepticYear, int month, int dayOfMonth)
Obtains a local date in Japanese calendar system from the proleptic-year, month-of-year and day-of-month fields.The Japanese proleptic year, month and day-of-month are the same as those in the ISO calendar system. They are not reset when the era changes.
- Specified by:
datein interfaceChronology- Parameters:
prolepticYear- the proleptic-yearmonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Japanese local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateYearDay
public JapaneseDate dateYearDay(Era era, int yearOfEra, int dayOfYear)
Obtains a local date in Japanese calendar system from the era, year-of-era and day-of-year fields.The day-of-year in this factory is expressed relative to the start of the year-of-era. This definition changes the normal meaning of day-of-year only in those years where the year-of-era is reset to one due to a change in the era. For example:
6th Jan Showa 64 = day-of-year 6 7th Jan Showa 64 = day-of-year 7 8th Jan Heisei 1 = day-of-year 1 9th Jan Heisei 1 = day-of-year 2
- Specified by:
dateYearDayin interfaceChronology- Parameters:
era- the Japanese era, not nullyearOfEra- the year-of-eradayOfYear- the day-of-year- Returns:
- the Japanese local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aJapaneseEra
-
dateYearDay
public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear)
Obtains a local date in Japanese calendar system from the proleptic-year and day-of-year fields.The day-of-year in this factory is expressed relative to the start of the proleptic year. The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. They are not reset when the era changes.
- Specified by:
dateYearDayin interfaceChronology- Parameters:
prolepticYear- the proleptic-yeardayOfYear- the day-of-year- Returns:
- the Japanese local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateEpochDay
public JapaneseDate dateEpochDay(long epochDay)
Obtains a local date in the Japanese calendar system from the epoch-day.- Specified by:
dateEpochDayin interfaceChronology- Parameters:
epochDay- the epoch day- Returns:
- the Japanese local date, not null
- Throws:
DateTimeException- if unable to create the date
-
isLeapYear
public boolean isLeapYear(long prolepticYear)
Checks if the specified year is a leap year.Japanese calendar leap years occur exactly in line with ISO leap years. This method does not validate the year passed in, and only has a well-defined result for years in the supported range.
- Specified by:
isLeapYearin interfaceChronology- Parameters:
prolepticYear- the proleptic-year to check, not validated for range- Returns:
- true if the year is a leap year
-
eraOf
public JapaneseEra eraOf(int eraValue)
Returns the calendar system era object from the given numeric value. See the description of each Era for the numeric values of:JapaneseEra.HEISEI,JapaneseEra.SHOWA,JapaneseEra.TAISHO,JapaneseEra.MEIJI), only Meiji and later eras are supported.- Specified by:
eraOfin interfaceChronology- Parameters:
eraValue- the era value- Returns:
- the Japanese
Erafor the given numeric era value - Throws:
DateTimeException- iferaValueis invalid
-
-