Top Description Methods
java.time.chrono

public Interface Chronology

extends Comparable<Chronology>
Known Direct Implementers
java.time.chrono.AbstractChronology
Static Imports
java.time.temporal.ChronoField.HOUR_OF_DAY, .ChronoField.MINUTE_OF_HOUR, .ChronoField.SECOND_OF_MINUTE

A calendar system, used to organize and identify dates.

The main date and time API is built on the ISO calendar system. The chronology operates behind the scenes to represent the general concept of a calendar system. For example, the Japanese, Minguo, Thai Buddhist and others.

Most other calendar systems also operate on the shared concepts of year, month and day, linked to the cycles of the Earth around the Sun, and the Moon around the Earth. These shared concepts are defined by ChronoField and are available for use by any Chronology implementation:

  LocalDate isoDate = ...
  ThaiBuddhistDate thaiDate = ...
  int isoYear = isoDate.get(ChronoField.YEAR);
  int thaiYear = thaiDate.get(ChronoField.YEAR);
As shown, although the date objects are in different calendar systems, represented by different Chronology instances, both can be queried using the same constant on ChronoField. For a full discussion of the implications of this, see ChronoLocalDate. In general, the advice is to use the known ISO-based LocalDate, rather than ChronoLocalDate.

While a Chronology object typically uses ChronoField and is based on an era, year-of-era, month-of-year, day-of-month model of a date, this is not required. A Chronology instance may represent a totally different kind of calendar system, such as the Mayan.

In practical terms, the Chronology instance also acts as a factory. The of(String) method allows an instance to be looked up by identifier, while the ofLocale(Locale) method allows lookup by locale.

The Chronology instance provides a set of methods to create ChronoLocalDate instances. The date classes are used to manipulate specific dates.

Adding New Calendars

The set of available chronologies can be extended by applications. Adding a new calendar system requires the writing of an implementation of Chronology, ChronoLocalDate and Era. The majority of the logic specific to the calendar system will be in the ChronoLocalDate implementation. The Chronology implementation acts as a factory.

To permit the discovery of additional chronologies, the ServiceLoader is used. A file must be added to the META-INF/services directory with the name 'java.time.chrono.Chronology' listing the implementation classes. See the ServiceLoader for more details on service loading. For lookup by id or calendarType, the system provided calendars are found first followed by application provided calendars.

Each chronology must define a chronology ID that is unique within the system. If the chronology represents a calendar system defined by the CLDR specification then the calendar type is the concatenation of the CLDR type and, if applicable, the CLDR variant.

Implementation Specification

This interface must be implemented with care to ensure other classes operate correctly. All implementations that can be instantiated must be final, immutable and thread-safe. Subclasses should be Serializable wherever possible.

Since
1.8

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the comparator value, that is this ID string compared with the other's ID string unless the ID strings are equal and the chronology distinguishes instances using additional information
compareTo
(Chronology
the other chronology to compare to, not null
other
)

Redeclares java.lang.Comparable.compareTo.

Compares this chronology to another chronology.
public default ChronoLocalDate

Returns:

the local date in this chronology, not null
date
(Era
the era of the correct type for the chronology, not null
era
,
int
the chronology year-of-era
yearOfEra
,
int
the chronology month-of-year
month
,
int
the chronology day-of-month
dayOfMonth
)

Obtains a local date in this chronology from the era, year-of-era, month-of-year and day-of-month fields.

public ChronoLocalDate

Returns:

the local date in this chronology, not null
date
(int
the chronology proleptic-year
prolepticYear
,
int
the chronology month-of-year
month
,
int
the chronology day-of-month
dayOfMonth
)

Obtains a local date in this chronology from the proleptic-year, month-of-year and day-of-month fields.

public ChronoLocalDate

Returns:

the local date in this chronology, not null
date
(TemporalAccessor
the temporal object to convert, not null
temporal
)

Obtains a local date in this chronology from another temporal object.

public ChronoLocalDate

Returns:

the local date in this chronology, not null
dateEpochDay
(long
the epoch day
epochDay
)

Obtains a local date in this chronology from the epoch-day.

public default ChronoLocalDate

Returns:

the current local date using the system clock and default time-zone, not null
dateNow
()

Obtains the current local date in this chronology from the system clock in the default time-zone.

public default ChronoLocalDate

Returns:

the current local date using the system clock, not null
dateNow
(ZoneId
the zone ID to use, not null
zone
)

Obtains the current local date in this chronology from the system clock in the specified time-zone.

public default ChronoLocalDate

Returns:

the current local date, not null
dateNow
(Clock
the clock to use, not null
clock
)

Obtains the current local date in this chronology from the specified clock.

public default ChronoLocalDate

Returns:

the local date in this chronology, not null
dateYearDay
(Era
the era of the correct type for the chronology, not null
era
,
int
the chronology year-of-era
yearOfEra
,
int
the chronology day-of-year
dayOfYear
)

Obtains a local date in this chronology from the era, year-of-era and day-of-year fields.

public ChronoLocalDate

Returns:

the local date in this chronology, not null
dateYearDay
(int
the chronology proleptic-year
prolepticYear
,
int
the chronology day-of-year
dayOfYear
)

Obtains a local date in this chronology from the proleptic-year and day-of-year fields.

public default long

Returns:

the number of seconds relative to 1970-01-01T00:00:00Z, may be negative
epochSecond
(int
the chronology proleptic-year
prolepticYear
,
int
the chronology month-of-year
month
,
int
the chronology day-of-month
dayOfMonth
,
int
the hour-of-day, from 0 to 23
hour
,
int
the minute-of-hour, from 0 to 59
minute
,
int
the second-of-minute, from 0 to 59
second
,
ZoneOffset
the zone offset, not null
zoneOffset
)

Gets the number of seconds from the epoch of 1970-01-01T00:00:00Z.

public default long

Returns:

the number of seconds relative to 1970-01-01T00:00:00Z, may be negative
epochSecond
(Era
the era of the correct type for the chronology, not null
era
,
int
the chronology year-of-era
yearOfEra
,
int
the chronology month-of-year
month
,
int
the chronology day-of-month
dayOfMonth
,
int
the hour-of-day, from 0 to 23
hour
,
int
the minute-of-hour, from 0 to 59
minute
,
int
the second-of-minute, from 0 to 59
second
,
ZoneOffset
the zone offset, not null
zoneOffset
)

Gets the number of seconds from the epoch of 1970-01-01T00:00:00Z.

public boolean

Returns:

true if this is equal to the other chronology
equals
(Object
the object to check, null returns false
obj
)

Checks if this chronology is equal to another chronology.

public Era

Returns:

the calendar system era, not null
eraOf
(int
the era value
eraValue
)

Creates the chronology era object from the numeric value.

public List<Era>

Returns:

the list of eras for the chronology, may be immutable, not null
eras
()

Gets the list of eras for the chronology.

public static Chronology

Returns:

the chronology, not null
from
(TemporalAccessor
the temporal to convert, not null
temporal
)

Obtains an instance of Chronology from a temporal object.

public static Set<Chronology>

Returns:

the independent, modifiable set of the available chronology IDs, not null
getAvailableChronologies
()

Returns the available chronologies.

public String

Returns:

the calendar system type, null if the calendar is not defined by CLDR/LDML
getCalendarType
()

Gets the calendar type of the calendar system.

public default String

Returns:

the text value of the chronology, not null
getDisplayName
(TextStyle
the style of the text required, not null
style
,
Locale
the locale to use, not null
locale
)

Gets the textual representation of this chronology.

public String

Returns:

the chronology ID, not null
getId
()

Gets the ID of the chronology.

public int

Returns:

a suitable hash code
hashCode
()

A hash code for this chronology.

public default boolean

Returns:

true only if all the fields of IsoFields are supported by this chronology. Otherwise, returns false.
isIsoBased
()

Checks if this chronology is ISO based.

public boolean

Returns:

true if the year is a leap year
isLeapYear
(long
the proleptic-year to check, not validated for range
prolepticYear
)

Checks if the specified year is a leap year.

public default ChronoLocalDateTime<? extends ChronoLocalDate>

Returns:

the local date-time in this chronology, not null
localDateTime
(TemporalAccessor
the temporal object to convert, not null
temporal
)

Obtains a local date-time in this chronology from another temporal object.

public static Chronology

Returns:

the chronology with the identifier requested, not null
of
(String
the chronology ID or calendar system type, not null
id
)

Obtains an instance of Chronology from a chronology ID or calendar system type.

public static Chronology

Returns:

the calendar system associated with the locale, not null
ofLocale
(Locale
the locale to use to obtain the calendar system, not null
locale
)

Obtains an instance of Chronology from a locale.

public default ChronoPeriod

Returns:

the period in terms of this chronology, not null
period
(int
the number of years, may be negative
years
,
int
the number of years, may be negative
months
,
int
the number of years, may be negative
days
)

Obtains a period for this chronology based on years, months and days.

public int

Returns:

the proleptic-year
prolepticYear
(Era
the era of the correct type for the chronology, not null
era
,
int
the chronology year-of-era
yearOfEra
)

Calculates the proleptic-year given the era and year-of-era.

public ValueRange

Returns:

the range of valid values for the field, not null
range
(ChronoField
the field to get the range for, not null
field
)

Gets the range of valid values for the specified field.

public ChronoLocalDate

Returns:

the resolved date, null if insufficient information to create a date
resolveDate
(Map<TemporalField, Long>
the map of fields to values, which can be updated, not null
fieldValues
,
ResolverStyle
the requested type of resolve, not null
resolverStyle
)

Resolves parsed ChronoField values into a date during parsing.

public String

Returns:

a string representation of this chronology, not null
toString
()

Outputs this chronology as a String.

public default ChronoZonedDateTime<? extends ChronoLocalDate>

Returns:

the zoned date-time in this chronology, not null
zonedDateTime
(TemporalAccessor
the temporal object to convert, not null
temporal
)

Obtains a ChronoZonedDateTime in this chronology from another temporal object.

public default ChronoZonedDateTime<? extends ChronoLocalDate>

Returns:

the zoned date-time, not null
zonedDateTime
(Instant
the instant to create the date-time from, not null
instant
,
ZoneId
the time-zone, not null
zone
)

Obtains a ChronoZonedDateTime in this chronology from an Instant.

Method Detail

compareToback to summary
public int compareTo(Chronology other)

Redeclares java.lang.Comparable.compareTo.

Compares this chronology to another chronology.

The comparison order first by the chronology ID string, then by any additional information specific to the subclass. It is "consistent with equals", as defined by Comparable.

Parameters
other:Chronology

the other chronology to compare to, not null

Returns:int

the comparator value, that is this ID string compared with the other's ID string unless the ID strings are equal and the chronology distinguishes instances using additional information

Annotations
@Override
dateback to summary
public default ChronoLocalDate date(Era era, int yearOfEra, int month, int dayOfMonth)

Obtains a local date in this chronology from the era, year-of-era, month-of-year and day-of-month fields.

Implementation Specification

The default implementation combines the era and year-of-era into a proleptic year before calling date(int, int, int).

Parameters
era:Era

the era of the correct type for the chronology, not null

yearOfEra:int

the chronology year-of-era

month:int

the chronology month-of-year

dayOfMonth:int

the chronology day-of-month

Returns:ChronoLocalDate

the local date in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date
ClassCastException:
if the era is not of the correct type for the chronology
dateback to summary
public ChronoLocalDate date(int prolepticYear, int month, int dayOfMonth)

Obtains a local date in this chronology from the proleptic-year, month-of-year and day-of-month fields.

Parameters
prolepticYear:int

the chronology proleptic-year

month:int

the chronology month-of-year

dayOfMonth:int

the chronology day-of-month

Returns:ChronoLocalDate

the local date in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date
dateback to summary
public ChronoLocalDate date(TemporalAccessor temporal)

Obtains a local date in this chronology from another temporal object.

This obtains a date in this chronology based on the specified temporal. A TemporalAccessor represents an arbitrary set of date and time information, which this factory converts to an instance of ChronoLocalDate.

The conversion typically uses the EPOCH_DAY field, which is standardized across calendar systems.

This method matches the signature of the functional interface TemporalQuery allowing it to be used as a query via method reference, aChronology::date.

Parameters
temporal:TemporalAccessor

the temporal object to convert, not null

Returns:ChronoLocalDate

the local date in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date
See Also
ChronoLocalDate#from(TemporalAccessor)
dateEpochDayback to summary
public ChronoLocalDate dateEpochDay(long epochDay)

Obtains a local date in this chronology from the epoch-day.

The definition of EPOCH_DAY is the same for all calendar systems, thus it can be used for conversion.

Parameters
epochDay:long

the epoch day

Returns:ChronoLocalDate

the local date in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date
dateNowback to summary
public default ChronoLocalDate dateNow()

Obtains the current local date in this chronology from the system clock in the default time-zone.

This will query the system clock in the default time-zone to obtain the current date.

Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Implementation Specification

The default implementation invokes dateNow(Clock).

Returns:ChronoLocalDate

the current local date using the system clock and default time-zone, not null

Exceptions
DateTimeException:
if unable to create the date
dateNowback to summary
public default ChronoLocalDate dateNow(ZoneId zone)

Obtains the current local date in this chronology from the system clock in the specified time-zone.

This will query the system clock to obtain the current date. Specifying the time-zone avoids dependence on the default time-zone.

Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Implementation Specification

The default implementation invokes dateNow(Clock).

Parameters
zone:ZoneId

the zone ID to use, not null

Returns:ChronoLocalDate

the current local date using the system clock, not null

Exceptions
DateTimeException:
if unable to create the date
dateNowback to summary
public default ChronoLocalDate dateNow(Clock clock)

Obtains the current local date in this chronology from the specified clock.

This will query the specified clock to obtain the current date - today. Using this method allows the use of an alternate clock for testing. The alternate clock may be introduced using dependency injection.

Implementation Specification

The default implementation invokes date(TemporalAccessor).

Parameters
clock:Clock

the clock to use, not null

Returns:ChronoLocalDate

the current local date, not null

Exceptions
DateTimeException:
if unable to create the date
dateYearDayback to summary
public default ChronoLocalDate dateYearDay(Era era, int yearOfEra, int dayOfYear)

Obtains a local date in this chronology from the era, year-of-era and day-of-year fields.

Implementation Specification

The default implementation combines the era and year-of-era into a proleptic year before calling dateYearDay(int, int).

Parameters
era:Era

the era of the correct type for the chronology, not null

yearOfEra:int

the chronology year-of-era

dayOfYear:int

the chronology day-of-year

Returns:ChronoLocalDate

the local date in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date
ClassCastException:
if the era is not of the correct type for the chronology
dateYearDayback to summary
public ChronoLocalDate dateYearDay(int prolepticYear, int dayOfYear)

Obtains a local date in this chronology from the proleptic-year and day-of-year fields.

Parameters
prolepticYear:int

the chronology proleptic-year

dayOfYear:int

the chronology day-of-year

Returns:ChronoLocalDate

the local date in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date
epochSecondback to summary
public default long epochSecond(int prolepticYear, int month, int dayOfMonth, int hour, int minute, int second, ZoneOffset zoneOffset)

Gets the number of seconds from the epoch of 1970-01-01T00:00:00Z.

The number of seconds is calculated using the proleptic-year, month, day-of-month, hour, minute, second, and zoneOffset.

Parameters
prolepticYear:int

the chronology proleptic-year

month:int

the chronology month-of-year

dayOfMonth:int

the chronology day-of-month

hour:int

the hour-of-day, from 0 to 23

minute:int

the minute-of-hour, from 0 to 59

second:int

the second-of-minute, from 0 to 59

zoneOffset:ZoneOffset

the zone offset, not null

Returns:long

the number of seconds relative to 1970-01-01T00:00:00Z, may be negative

Exceptions
DateTimeException:
if any of the values are out of range
Since
9
epochSecondback to summary
public default long epochSecond(Era era, int yearOfEra, int month, int dayOfMonth, int hour, int minute, int second, ZoneOffset zoneOffset)

Gets the number of seconds from the epoch of 1970-01-01T00:00:00Z.

The number of seconds is calculated using the era, year-of-era, month, day-of-month, hour, minute, second, and zoneOffset.

Parameters
era:Era

the era of the correct type for the chronology, not null

yearOfEra:int

the chronology year-of-era

month:int

the chronology month-of-year

dayOfMonth:int

the chronology day-of-month

hour:int

the hour-of-day, from 0 to 23

minute:int

the minute-of-hour, from 0 to 59

second:int

the second-of-minute, from 0 to 59

zoneOffset:ZoneOffset

the zone offset, not null

Returns:long

the number of seconds relative to 1970-01-01T00:00:00Z, may be negative

Exceptions
DateTimeException:
if any of the values are out of range
Since
9
equalsback to summary
public boolean equals(Object obj)

Checks if this chronology is equal to another chronology.

The comparison is based on the entire state of the object.

Parameters
obj:Object

the object to check, null returns false

Returns:boolean

true if this is equal to the other chronology

Annotations
@Override
eraOfback to summary
public Era eraOf(int eraValue)

Creates the chronology era object from the numeric value.

The era is, conceptually, the largest division of the time-line. Most calendar systems have a single epoch dividing the time-line into two eras. However, some have multiple eras, such as one for the reign of each leader. The exact meaning is determined by the chronology according to the following constraints.

The era in use at 1970-01-01 must have the value 1. Later eras must have sequentially higher values. Earlier eras must have sequentially lower values. Each chronology must refer to an enum or similar singleton to provide the era values.

This method returns the singleton era of the correct type for the specified era value.

Parameters
eraValue:int

the era value

Returns:Era

the calendar system era, not null

Exceptions
DateTimeException:
if unable to create the era
erasback to summary
public List<Era> eras()

Gets the list of eras for the chronology.

Most calendar systems have an era, within which the year has meaning. If the calendar system does not support the concept of eras, an empty list must be returned.

Returns:List<Era>

the list of eras for the chronology, may be immutable, not null

fromback to summary
public static Chronology from(TemporalAccessor temporal)

Obtains an instance of Chronology from a temporal object.

This obtains a chronology based on the specified temporal. A TemporalAccessor represents an arbitrary set of date and time information, which this factory converts to an instance of Chronology.

The conversion will obtain the chronology using TemporalQueries#chronology(). If the specified temporal object does not have a chronology, IsoChronology is returned.

This method matches the signature of the functional interface TemporalQuery allowing it to be used as a query via method reference, Chronology::from.

Parameters
temporal:TemporalAccessor

the temporal to convert, not null

Returns:Chronology

the chronology, not null

Exceptions
DateTimeException:
if unable to convert to a Chronology
getAvailableChronologiesback to summary
public static Set<Chronology> getAvailableChronologies()

Returns the available chronologies.

Each returned Chronology is available for use in the system. The set of chronologies includes the system chronologies and any chronologies provided by the application via ServiceLoader configuration.

Returns:Set<Chronology>

the independent, modifiable set of the available chronology IDs, not null

getCalendarTypeback to summary
public String getCalendarType()

Gets the calendar type of the calendar system.

The calendar type is an identifier defined by the CLDR and Unicode Locale Data Markup Language (LDML) specifications to uniquely identify a calendar. The getCalendarType is the concatenation of the CLDR calendar type and the variant, if applicable, is appended separated by "-". The calendar type is used to lookup the Chronology using of(String).

Returns:String

the calendar system type, null if the calendar is not defined by CLDR/LDML

See Also
getId()
getDisplayNameback to summary
public default String getDisplayName(TextStyle style, Locale locale)

Gets the textual representation of this chronology.

This returns the textual name used to identify the chronology, suitable for presentation to the user. The parameters control the style of the returned text and the locale.

Implementation Specification

The default implementation behaves as though the formatter was used to format the chronology textual name.

Parameters
style:TextStyle

the style of the text required, not null

locale:Locale

the locale to use, not null

Returns:String

the text value of the chronology, not null

getIdback to summary
public String getId()

Gets the ID of the chronology.

The ID uniquely identifies the Chronology. It can be used to lookup the Chronology using of(String).

Returns:String

the chronology ID, not null

See Also
getCalendarType()
hashCodeback to summary
public int hashCode()

A hash code for this chronology.

The hash code should be based on the entire state of the object.

Returns:int

a suitable hash code

Annotations
@Override
isIsoBasedback to summary
public default boolean isIsoBased()

Checks if this chronology is ISO based.

An ISO based chronology has the same basic structure as the ISO chronology, i.e., the chronology has the same number of months, the number of days in each month, and day-of-year and leap years are the same as ISO chronology. It also supports the concept of week-based-year of ISO chronology. For example, the Minguo, ThaiThaiBuddhist and Japanese chronologies are ISO based.

Implementation Specification

The default implementation returns false.

Returns:boolean

true only if all the fields of IsoFields are supported by this chronology. Otherwise, returns false.

Since
19
See Also
IsoChronology, JapaneseChronology, MinguoChronology, ThaiBuddhistChronology, IsoFields
isLeapYearback to summary
public boolean isLeapYear(long prolepticYear)

Checks if the specified year is a leap year.

A leap-year is a year of a longer length than normal. The exact meaning is determined by the chronology according to the following constraints.

  • a leap-year must imply a year-length longer than a non leap-year.
  • a chronology that does not support the concept of a year must return false.
  • the correct result must be returned for all years within the valid range of years for the chronology.

Outside the range of valid years an implementation is free to return either a best guess or false. An implementation must not throw an exception, even if the year is outside the range of valid years.

Parameters
prolepticYear:long

the proleptic-year to check, not validated for range

Returns:boolean

true if the year is a leap year

localDateTimeback to summary
public default ChronoLocalDateTime<? extends ChronoLocalDate> localDateTime(TemporalAccessor temporal)

Obtains a local date-time in this chronology from another temporal object.

This obtains a date-time in this chronology based on the specified temporal. A TemporalAccessor represents an arbitrary set of date and time information, which this factory converts to an instance of ChronoLocalDateTime.

The conversion extracts and combines the ChronoLocalDate and the LocalTime from the temporal object. Implementations are permitted to perform optimizations such as accessing those fields that are equivalent to the relevant objects. The result uses this chronology.

This method matches the signature of the functional interface TemporalQuery allowing it to be used as a query via method reference, aChronology::localDateTime.

Parameters
temporal:TemporalAccessor

the temporal object to convert, not null

Returns:ChronoLocalDateTime<? extends ChronoLocalDate>

the local date-time in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date-time
See Also
ChronoLocalDateTime#from(TemporalAccessor)
ofback to summary
public static Chronology of(String id)

Obtains an instance of Chronology from a chronology ID or calendar system type.

This returns a chronology based on either the ID or the type. The chronology ID uniquely identifies the chronology. The calendar system type is defined by the CLDR specification.

The chronology may be a system chronology or a chronology provided by the application via ServiceLoader configuration.

Since some calendars can be customized, the ID or type typically refers to the default customization. For example, the Gregorian calendar can have multiple cutover dates from the Julian, but the lookup only provides the default cutover date.

Parameters
id:String

the chronology ID or calendar system type, not null

Returns:Chronology

the chronology with the identifier requested, not null

Exceptions
DateTimeException:
if the chronology cannot be found
ofLocaleback to summary
public static Chronology ofLocale(Locale locale)

Obtains an instance of Chronology from a locale.

This returns a Chronology based on the specified locale, typically returning IsoChronology. Other calendar systems are only returned if they are explicitly selected within the locale.

The Locale class provide access to a range of information useful for localizing an application. This includes the language and region, such as "en-GB" for English as used in Great Britain.

The Locale class also supports an extension mechanism that can be used to identify a calendar system. The mechanism is a form of key-value pairs, where the calendar system has the key "ca". For example, the locale "en-JP-u-ca-japanese" represents the English language as used in Japan with the Japanese calendar system.

This method finds the desired calendar system in a manner equivalent to passing "ca" to Locale#getUnicodeLocaleType(String). If the "ca" key is not present, then IsoChronology is returned.

Note that the behavior of this method differs from the older java.util.Calendar#getInstance(Locale) method. If that method receives a locale of "th_TH" it will return BuddhistCalendar. By contrast, this method will return IsoChronology. Passing the locale "th-TH-u-ca-buddhist" into either method will result in the Thai Buddhist calendar system and is therefore the recommended approach going forward for Thai calendar system localization.

A similar, but simpler, situation occurs for the Japanese calendar system. The locale "jp_JP_JP" has previously been used to access the calendar. However, unlike the Thai locale, "ja_JP_JP" is automatically converted by Locale to the modern and recommended form of "ja-JP-u-ca-japanese". Thus, there is no difference in behavior between this method and Calendar#getInstance(Locale).

Parameters
locale:Locale

the locale to use to obtain the calendar system, not null

Returns:Chronology

the calendar system associated with the locale, not null

Exceptions
DateTimeException:
if the locale-specified calendar cannot be found
periodback to summary
public default ChronoPeriod period(int years, int months, int days)

Obtains a period for this chronology based on years, months and days.

This returns a period tied to this chronology using the specified years, months and days. All supplied chronologies use periods based on years, months and days, however the ChronoPeriod API allows the period to be represented using other units.

Implementation Specification

The default implementation returns an implementation class suitable for most calendar systems. It is based solely on the three units. Normalization, addition and subtraction derive the number of months in a year from the range(ChronoField). If the number of months within a year is fixed, then the calculation approach for addition, subtraction and normalization is slightly different.

If implementing an unusual calendar system that is not based on years, months and days, or where you want direct control, then the ChronoPeriod interface must be directly implemented.

The returned period is immutable and thread-safe.

Parameters
years:int

the number of years, may be negative

months:int

the number of years, may be negative

days:int

the number of years, may be negative

Returns:ChronoPeriod

the period in terms of this chronology, not null

prolepticYearback to summary
public int prolepticYear(Era era, int yearOfEra)

Calculates the proleptic-year given the era and year-of-era.

This combines the era and year-of-era into the single proleptic-year field.

If the chronology makes active use of eras, such as JapaneseChronology then the year-of-era will be validated against the era. For other chronologies, validation is optional.

Parameters
era:Era

the era of the correct type for the chronology, not null

yearOfEra:int

the chronology year-of-era

Returns:int

the proleptic-year

Exceptions
DateTimeException:
if unable to convert to a proleptic-year, such as if the year is invalid for the era
ClassCastException:
if the era is not of the correct type for the chronology
rangeback to summary
public ValueRange range(ChronoField field)

Gets the range of valid values for the specified field.

All fields can be expressed as a long integer. This method returns an object that describes the valid range for that value.

Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field.

This method will return a result whether or not the chronology supports the field.

Parameters
field:ChronoField

the field to get the range for, not null

Returns:ValueRange

the range of valid values for the field, not null

Exceptions
DateTimeException:
if the range for the field cannot be obtained
resolveDateback to summary
public ChronoLocalDate resolveDate(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle)

Resolves parsed ChronoField values into a date during parsing.

Most TemporalField implementations are resolved using the resolve method on the field. By contrast, the ChronoField class defines fields that only have meaning relative to the chronology. As such, ChronoField date fields are resolved here in the context of a specific chronology.

The default implementation, which explains typical resolve behaviour, is provided in AbstractChronology.

Parameters
fieldValues:Map<TemporalField, Long>

the map of fields to values, which can be updated, not null

resolverStyle:ResolverStyle

the requested type of resolve, not null

Returns:ChronoLocalDate

the resolved date, null if insufficient information to create a date

Exceptions
DateTimeException:
if the date cannot be resolved, typically because of a conflict in the input data
toStringback to summary
public String toString()

Outputs this chronology as a String.

The format should include the entire state of the object.

Returns:String

a string representation of this chronology, not null

Annotations
@Override
zonedDateTimeback to summary
public default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal)

Obtains a ChronoZonedDateTime in this chronology from another temporal object.

This obtains a zoned date-time in this chronology based on the specified temporal. A TemporalAccessor represents an arbitrary set of date and time information, which this factory converts to an instance of ChronoZonedDateTime.

The conversion will first obtain a ZoneId from the temporal object, falling back to a ZoneOffset if necessary. It will then try to obtain an Instant, falling back to a ChronoLocalDateTime if necessary. The result will be either the combination of ZoneId or ZoneOffset with Instant or ChronoLocalDateTime. Implementations are permitted to perform optimizations such as accessing those fields that are equivalent to the relevant objects. The result uses this chronology.

This method matches the signature of the functional interface TemporalQuery allowing it to be used as a query via method reference, aChronology::zonedDateTime.

Parameters
temporal:TemporalAccessor

the temporal object to convert, not null

Returns:ChronoZonedDateTime<? extends ChronoLocalDate>

the zoned date-time in this chronology, not null

Exceptions
DateTimeException:
if unable to create the date-time
See Also
ChronoZonedDateTime#from(TemporalAccessor)
zonedDateTimeback to summary
public default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(Instant instant, ZoneId zone)

Obtains a ChronoZonedDateTime in this chronology from an Instant.

This obtains a zoned date-time with the same instant as that specified.

Parameters
instant:Instant

the instant to create the date-time from, not null

zone:ZoneId

the time-zone, not null

Returns:ChronoZonedDateTime<? extends ChronoLocalDate>

the zoned date-time, not null

Exceptions
DateTimeException:
if the result exceeds the supported range