Compares this chronology to another chronology.
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
.
The default implementation compares the chronology ID. Subclasses must compare any additional state that they store.
the other chronology to compare to, not null
the comparator value, negative if less, positive if greater
Obtains an ISO local date from another date-time object.
Obtains an ISO local date from another date-time object.
This is equivalent to LocalDate#from(TemporalAccessor)
.
the date-time object to convert, not null
the ISO local date, not null
DateTimeException
if unable to create the date
Obtains an ISO local date from the proleptic-year, month-of-year and day-of-month fields.
Obtains an ISO local date from the proleptic-year, month-of-year and day-of-month fields.
This is equivalent to int, int)
.
the ISO proleptic-year
the ISO month-of-year
the ISO day-of-month
the ISO local date, not null
DateTimeException
if unable to create the date
Obtains an ISO local date from the era, year-of-era, month-of-year and day-of-month fields.
Obtains an ISO local date from the era, year-of-era, month-of-year and day-of-month fields.
the ISO era, not null
the ISO year-of-era
the ISO month-of-year
the ISO day-of-month
the ISO local date, not null
DateTimeException
if unable to create the date
Obtains a local date in this chronology from the epoch-day.
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.
the epoch day
the local date in this chronology, not null
DateTimeException
if unable to create the date
Obtains the current ISO local date from the specified clock.
Obtains the current ISO local date 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
.
the clock to use, not null
the current ISO local date, not null
DateTimeException
if unable to create the date
Obtains the current ISO local date from the system clock in the specified time-zone.
Obtains the current ISO local date 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.
the zone ID to use, not null
the current ISO local date using the system clock, not null
DateTimeException
if unable to create the date
Obtains the current ISO local date from the system clock in the default time-zone.
Obtains the current ISO local date 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.
the current ISO local date using the system clock and default time-zone, not null
DateTimeException
if unable to create the date
Obtains an ISO local date from the proleptic-year and day-of-year fields.
Obtains an ISO local date from the proleptic-year and day-of-year fields.
This is equivalent to int)
.
the ISO proleptic-year
the ISO day-of-year
the ISO local date, not null
DateTimeException
if unable to create the date
Obtains an ISO local date from the era, year-of-era and day-of-year fields.
Obtains an ISO local date from the era, year-of-era and day-of-year fields.
the ISO era, not null
the ISO year-of-era
the ISO day-of-year
the ISO local date, not null
DateTimeException
if unable to create the date
Checks if this chronology is equal to another chronology.
Checks if this chronology is equal to another chronology.
The comparison is based on the entire state of the object.
The default implementation checks the type and calls #compareTo(Chronology)
.
the object to check, null returns false
true if this is equal to the other chronology
Creates the chronology era object from the numeric value.
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.
the era value
the calendar system era, not null
DateTimeException
if unable to create the era
Gets the list of eras for the chronology.
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.
the list of eras for the chronology, may be immutable, not null
Gets the calendar type of the underlying calendar system - 'iso8601'.
Gets the calendar type of the underlying calendar system - 'iso8601'.
The calendar type is an identifier defined by the
Unicode Locale Data Markup Language (LDML) specification.
It can be used to lookup the Chronology
using #of(String)
.
It can also be used as part of a locale, accessible via
Locale#getUnicodeLocaleType(String)
with the key 'ca'.
the calendar system type - 'iso8601'
#getId()
Gets the textual representation of this chronology.
Gets the textual representation of this chronology.
This returns the textual name used to identify the chronology. The parameters control the style of the returned text and the locale.
the style of the text required, not null
the locale to use, not null
the text value of the chronology, not null
Gets the ID of the chronology - 'ISO'.
Gets the ID of the chronology - 'ISO'.
The ID uniquely identifies the Chronology
.
It can be used to lookup the Chronology
using #of(String)
.
the chronology ID - 'ISO'
#getCalendarType()
A hash code for this chronology.
A hash code for this chronology.
The default implementation is based on the ID and class. Subclasses should add any additional state that they store.
a suitable hash code
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
This method applies the current rules for leap years across the whole time-line. In general, a year is a leap year if it is divisible by four without remainder. However, years divisible by 100, are not leap years, with the exception of years divisible by 400 which are.
For example, 1904 is a leap year it is divisible by 4. 1900 was not a leap year as it is divisible by 100, however 2000 was a leap year as it is divisible by 400.
The calculation is proleptic - applying the same rules into the far future and far past. This is historically inaccurate, but is correct for the ISO-8601 standard.
the ISO proleptic year to check
true if the year is leap, false otherwise
Obtains an ISO local date-time from another date-time object.
Obtains an ISO local date-time from another date-time object.
This is equivalent to LocalDateTime#from(TemporalAccessor)
.
the date-time object to convert, not null
the ISO local date-time, not null
DateTimeException
if unable to create the date-time
Obtains a period for this chronology based on years, months and 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.
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.
the number of years, may be negative
the number of years, may be negative
the number of years, may be negative
the period in terms of this chronology, not null
Calculates the proleptic-year given the era and year-of-era.
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.
the era of the correct type for the chronology, not null
the chronology year-of-era
the proleptic-year
ClassCastException
if the { @code era} is not of the correct type for the chronology
DateTimeException
if unable to convert
Gets the range of valid values for the specified 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.
the field to get the range for, not null
the range of valid values for the field, not null
DateTimeException
if the range for the field cannot be obtained
Resolves parsed ChronoField
values into a date during parsing.
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
.
the map of fields to values, which can be updated, not null
the requested type of resolve, not null
the resolved date, null if insufficient information to create a date
DateTimeException
if the date cannot be resolved, typically
because of a conflict in the input data
Outputs this chronology as a String
, using the ID.
Outputs this chronology as a String
, using the ID.
a string representation of this chronology, not null
Obtains an ISO zoned date-time from an instant.
Obtains an ISO zoned date-time from an instant.
This is equivalent to ZoneId)
.
the instant to convert, not null
the zone to use, not null
the ISO zoned date-time, not null
DateTimeException
if unable to create the date-time
Obtains an ISO zoned date-time from another date-time object.
Obtains an ISO zoned date-time from another date-time object.
This is equivalent to ZonedDateTime#from(TemporalAccessor)
.
the date-time object to convert, not null
the ISO zoned date-time, not null
DateTimeException
if unable to create the date-time
The ISO calendar system.
This chronology defines the rules of the ISO calendar system. This calendar system is based on the ISO-8601 standard, which is the de facto world calendar.
The fields are defined as follows:
Specification for implementors
This class is immutable and thread-safe.