public final class IsoChronology extends AbstractChronologyimplements Serializable
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:
| Modifier and Type | Field and Description |
|---|---|
static IsoChronology |
INSTANCE
Singleton instance of the ISO chronology.
|
| Modifier and Type | Method and Description |
|---|---|
LocalDate |
date(Era
Obtains an ISO local date from the era, year-of-era, month-of-year and day-of-month fields.
|
LocalDate |
date(int prolepticYear, int month, int dayOfMonth)
Obtains an ISO local date from the proleptic-year, month-of-year and day-of-month fields.
|
LocalDate |
date(TemporalAccessor
Obtains an ISO local date from another date-time object.
|
LocalDate |
dateEpochDay(long epochDay)
Obtains an ISO local date from the epoch-day.
|
LocalDate |
dateNow()
Obtains the current ISO local date from the system clock in the default time-zone.
|
LocalDate |
dateNow(Clock
Obtains the current ISO local date from the specified clock.
|
LocalDate |
dateNow(ZoneId
Obtains the current ISO local date from the system clock in the specified time-zone.
|
LocalDate |
dateYearDay(Era
Obtains an ISO local date from the era, year-of-era and day-of-year fields.
|
LocalDate |
dateYearDay(int prolepticYear, int dayOfYear)
Obtains an ISO local date from the proleptic-year and day-of-year fields.
|
IsoEra |
eraOf(int eraValue)
Creates the chronology era object from the numeric value.
|
List |
eras()
Gets the list of eras for the chronology.
|
String |
getCalendarType()
Gets the calendar type of the underlying calendar system - 'iso8601'.
|
String |
getId()
Gets the ID of the chronology - 'ISO'.
|
boolean |
isLeapYear(long prolepticYear)
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
|
LocalDateTime |
localDateTime(TemporalAccessor
Obtains an ISO local date-time from another date-time object.
|
Period |
period(int years, int months, int days)
Obtains a period for this chronology based on years, months and days.
|
int |
prolepticYear(Era
Calculates the proleptic-year given the era and year-of-era.
|
ValueRange |
range(ChronoField
Gets the range of valid values for the specified field.
|
LocalDate |
resolveDate(Map
Resolves parsed
ChronoField values into a date during parsing.
|
ZonedDateTime |
zonedDateTime(Instant
Obtains an ISO zoned date-time in this chronology from an
Instant.
|
ZonedDateTime |
zonedDateTime(TemporalAccessor
Obtains an ISO zoned date-time from another date-time object.
|
compareTo, equals, hashCode, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitfrom, getDisplayNamepublic static final IsoChronologyINSTANCE
public StringgetId()
The ID uniquely identifies the Chronology. It can be used to lookup the Chronology using AbstractChronology.
getId in interface
Chronology
getCalendarType()
public StringgetCalendarType()
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 AbstractChronology. It can also be used as part of a locale, accessible via Locale with the key 'ca'.
getCalendarType in interface
Chronology
getId()
public LocalDatedate(Era era, int yearOfEra, int month, int dayOfMonth)
date in interface
Chronology
era - the ISO era, not null
yearOfEra - the ISO year-of-era
month - the ISO month-of-year
dayOfMonth - the ISO day-of-month
DateTimeException - if unable to create the date
ClassCastException - if the type of
era is not
IsoEra
public LocalDatedate(int prolepticYear, int month, int dayOfMonth)
This is equivalent to LocalDate.
date in interface
Chronology
prolepticYear - the ISO proleptic-year
month - the ISO month-of-year
dayOfMonth - the ISO day-of-month
DateTimeException - if unable to create the date
public LocalDatedateYearDay(Era era, int yearOfEra, int dayOfYear)
dateYearDay in interface
Chronology
era - the ISO era, not null
yearOfEra - the ISO year-of-era
dayOfYear - the ISO day-of-year
DateTimeException - if unable to create the date
public LocalDatedateYearDay(int prolepticYear, int dayOfYear)
This is equivalent to LocalDate.
dateYearDay in interface
Chronology
prolepticYear - the ISO proleptic-year
dayOfYear - the ISO day-of-year
DateTimeException - if unable to create the date
public LocalDatedateEpochDay(long epochDay)
This is equivalent to LocalDate.
dateEpochDay in interface
Chronology
epochDay - the epoch day
DateTimeException - if unable to create the date
public LocalDatedate(TemporalAccessor temporal)
This is equivalent to LocalDate.
date in interface
Chronology
temporal - the date-time object to convert, not null
DateTimeException - if unable to create the date
ChronoLocalDate.from(TemporalAccessor)
public LocalDateTimelocalDateTime(TemporalAccessor temporal)
This is equivalent to LocalDateTime.
localDateTime in interface
Chronology
temporal - the date-time object to convert, not null
DateTimeException - if unable to create the date-time
ChronoLocalDateTime.from(TemporalAccessor)
public ZonedDateTimezonedDateTime(TemporalAccessor temporal)
This is equivalent to ZonedDateTime.
zonedDateTime in interface
Chronology
temporal - the date-time object to convert, not null
DateTimeException - if unable to create the date-time
ChronoZonedDateTime.from(TemporalAccessor)
public ZonedDateTimezonedDateTime(Instant instant, ZoneId zone)
Instant.
This is equivalent to ZonedDateTime.
zonedDateTime in interface
Chronology
instant - the instant to create the date-time from, not null
zone - the time-zone, not null
DateTimeException - if the result exceeds the supported range
public LocalDatedateNow()
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.
dateNow in interface
Chronology
DateTimeException - if unable to create the date
public LocalDatedateNow(ZoneId 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.
dateNow in interface
Chronology
zone - the zone ID to use, not null
DateTimeException - if unable to create the date
public LocalDatedateNow(Clock 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.
dateNow in interface
Chronology
clock - the clock to use, not null
DateTimeException - if unable to create the date
public boolean isLeapYear(long prolepticYear)
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.
isLeapYear in interface
Chronology
prolepticYear - the ISO proleptic year to check
public int prolepticYear(Eraera, int yearOfEra)
Chronology
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.
prolepticYear in interface
Chronology
era - the era of the correct type for the chronology, not null
yearOfEra - the chronology year-of-era
public IsoEraeraOf(int eraValue)
Chronology
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.
eraOf in interface
Chronology
eraValue - the era value
public List<Era > eras()
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.
eras in interface
Chronology
public LocalDateresolveDate(Map <TemporalField ,Long > fieldValues, ResolverStyle resolverStyle)
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.
ChronoField instances on the ISO calendar system are resolved as follows.
EPOCH_DAY - If present, this is converted to a LocalDate and all other date fields are then cross-checked against the date. PROLEPTIC_MONTH - If present, then it is split into the YEAR and MONTH_OF_YEAR. If the mode is strict or smart then the field is validated. YEAR_OF_ERA and ERA - If both are present, then they are combined to form a YEAR. In lenient mode, the YEAR_OF_ERA range is not validated, in smart and strict mode it is. The ERA is validated for range in all three modes. If only the YEAR_OF_ERA is present, and the mode is smart or lenient, then the current era (CE/AD) is assumed. In strict mode, no era is assumed and the YEAR_OF_ERA is left untouched. If only the ERA is present, then it is left untouched. YEAR, MONTH_OF_YEAR and DAY_OF_MONTH - If all three are present, then they are combined to form a LocalDate. In all three modes, the YEAR is validated. If the mode is smart or strict, then the month and day are validated, with the day validated from 1 to 31. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first of January in the requested year, then adding the difference in months, then the difference in days. If the mode is smart, and the day-of-month is greater than the maximum for the year-month, then the day-of-month is adjusted to the last day-of-month. If the mode is strict, then the three fields must form a valid date. YEAR and DAY_OF_YEAR - If both are present, then they are combined to form a LocalDate. In all three modes, the YEAR is validated. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first of January in the requested year, then adding the difference in days. If the mode is smart or strict, then the two fields must form a valid date. YEAR, MONTH_OF_YEAR, ALIGNED_WEEK_OF_MONTH and ALIGNED_DAY_OF_WEEK_IN_MONTH - If all four are present, then they are combined to form a LocalDate. In all three modes, the YEAR is validated. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first of January in the requested year, then adding the difference in months, then the difference in weeks, then in days. If the mode is smart or strict, then the all four fields are validated to their outer ranges. The date is then combined in a manner equivalent to creating a date on the first day of the requested year and month, then adding the amount in weeks and days to reach their values. If the mode is strict, the date is additionally validated to check that the day and week adjustment did not change the month. YEAR, MONTH_OF_YEAR, ALIGNED_WEEK_OF_MONTH and DAY_OF_WEEK - If all four are present, then they are combined to form a LocalDate. The approach is the same as described above for years, months and weeks in ALIGNED_DAY_OF_WEEK_IN_MONTH. The day-of-week is adjusted as the next or same matching day-of-week once the years, months and weeks have been handled. YEAR, ALIGNED_WEEK_OF_YEAR and ALIGNED_DAY_OF_WEEK_IN_YEAR - If all three are present, then they are combined to form a LocalDate. In all three modes, the YEAR is validated. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first of January in the requested year, then adding the difference in weeks, then in days. If the mode is smart or strict, then the all three fields are validated to their outer ranges. The date is then combined in a manner equivalent to creating a date on the first day of the requested year, then adding the amount in weeks and days to reach their values. If the mode is strict, the date is additionally validated to check that the day and week adjustment did not change the year. YEAR, ALIGNED_WEEK_OF_YEAR and DAY_OF_WEEK - If all three are present, then they are combined to form a LocalDate. The approach is the same as described above for years and weeks in ALIGNED_DAY_OF_WEEK_IN_YEAR. The day-of-week is adjusted as the next or same matching day-of-week once the years and weeks have been handled. resolveDate in interface
Chronology
resolveDate in class
AbstractChronology
fieldValues - the map of fields to values, which can be updated, not null
resolverStyle - the requested type of resolve, not null
DateTimeException - if the date cannot be resolved, typically because of a conflict in the input data
public ValueRangerange(ChronoField field)
Chronology
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.
range in interface
Chronology
field - the field to get the range for, not null
public Periodperiod(int years, int months, int days)
This returns a period tied to the ISO chronology using the specified years, months and days. See Period for further details.
period in interface
Chronology
years - the number of years, may be negative
months - the number of years, may be negative
days - the number of years, may be negative