Compares this chronology to another chronology. !(p) 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 {@link Comparable}.
Obtains a local date _in this chronology from the era, year-of-era, month-of-year and day-of-month fields.
Obtains a local date _in this chronology from the proleptic-year, month-of-year and day-of-month fields.
Obtains a local date _in this chronology from another temporal object. !(p) This obtains a date _in this chronology based on the specified temporal. A {@code TemporalAccessor} represents an arbitrary set of date and time information, which this factory converts to an instance of {@code ChronoLocalDate}. !(p) The conversion typically uses the {@link ChronoField#EPOCH_DAY EPOCH_DAY} field, which is standardized across calendar systems. !(p) This method matches the signature of the functional interface {@link TemporalQuery} allowing it to be used as a query via method reference, {@code aChronology::date}.
Obtains a local date _in this chronology from the epoch-day. !(p) The definition of {@link ChronoField#EPOCH_DAY EPOCH_DAY} is the same for all calendar systems, thus it can be used for conversion.
Obtains the current local date _in this chronology from the system clock _in the time-zone. !(p) This will query the {@link Clock#systemDefaultZone() system clock} _in the time-zone to obtain the current date. !(p) Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
Obtains the current local date _in this chronology from the system clock _in the specified time-zone. !(p) This will query the {@link Clock#system(ZoneId) system clock} to obtain the current date. Specifying the time-zone avoids dependence on the time-zone. !(p) Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
Obtains the current local date _in this chronology from the specified clock. !(p) 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 {@link Clock dependency injection}.
Obtains a local date _in this chronology from the era, year-of-era and day-of-year fields.
Obtains a local date _in this chronology from the proleptic-year and day-of-year fields.
Gets the number of seconds from the epoch of 1970-01-01T00:00:00Z. !(p) The number of seconds is calculated using the proleptic-year, month, day-of-month, hour, minute, second, and zoneOffset.
Gets the number of seconds from the epoch of 1970-01-01T00:00:00Z. !(p) The number of seconds is calculated using the era, year-of-era, month, day-of-month, hour, minute, second, and zoneOffset.
Creates the chronology era object from the numeric value. !(p) 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. !(p) 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. !(p) This method returns the singleton era of the correct type for the specified era value.
Gets the list of eras for the chronology. !(p) 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.
Gets the calendar type of the calendar system. !(p) The calendar type is an identifier defined by the CLDR and !(em)Unicode Locale Data Markup Language (LDML)</em> specifications to uniquely identify a calendar. The {@code 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 {@code Chronology} using {@link #of(string)}.
Gets the ID of the chronology. !(p) The ID uniquely identifies the {@code Chronology}. It can be used to lookup the {@code Chronology} using {@link #of(string)}.
Checks if the specified year is a leap year. !(p) 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. !(ul) !(li)a leap-year must imply a year-length longer than a non leap-year. !(li)a chronology that does not support the concept of a year must return false. !(li)the correct result must be returned for all years within the valid range of years for the chronology. </ul> !(p) 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.
Obtains a local date-time _in this chronology from another temporal object. !(p) This obtains a date-time _in this chronology based on the specified temporal. A {@code TemporalAccessor} represents an arbitrary set of date and time information, which this factory converts to an instance of {@code ChronoLocalDateTime}. !(p) The conversion extracts and combines the {@code ChronoLocalDate} and the {@code 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. !(p) This method matches the signature of the functional interface {@link TemporalQuery} allowing it to be used as a query via method reference, {@code aChronology::localDateTime}.
Obtains a period for this chronology based on years, months and days. !(p) 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 {@code ChronoPeriod} API allows the period to be represented using other units.
Calculates the proleptic-year given the era and year-of-era. !(p) This combines the era and year-of-era into the single proleptic-year field. !(p) If the chronology makes active use of eras, such as {@code JapaneseChronology} then the year-of-era will be validated against the era. For other chronologies, validation is optional.
Gets the range of valid values for the specified field. !(p) All fields can be expressed as a {@code long} integer. This method returns an object that describes the valid range for that value. !(p) 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. !(p) This method will return a result whether or not the chronology supports the field.
Resolves parsed {@code ChronoField} values into a date during parsing. !(p) Most {@code TemporalField} implementations are resolved using the resolve method on the field. By contrast, the {@code ChronoField} class defines fields that only have meaning relative to the chronology. As such, {@code ChronoField} date fields are resolved here _in the context of a specific chronology. !(p) The implementation, which explains typical resolve behaviour, is provided _in {@link AbstractChronology}.
A hash code for this chronology. !(p) The hash code should be based on the entire state of the object.
Outputs this chronology as a {@code string}. !(p) The format should include the entire state of the object.
Obtains a {@code ChronoZonedDateTime} _in this chronology from another temporal object. !(p) This obtains a zoned date-time _in this chronology based on the specified temporal. A {@code TemporalAccessor} represents an arbitrary set of date and time information, which this factory converts to an instance of {@code ChronoZonedDateTime}. !(p) The conversion will first obtain a {@code ZoneId} from the temporal object, falling back to a {@code ZoneOffset} if necessary. It will then try to obtain an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary. The result will be either the combination of {@code ZoneId} or {@code ZoneOffset} with {@code Instant} or {@code ChronoLocalDateTime}. Implementations are permitted to perform optimizations such as accessing those fields that are equivalent to the relevant objects. The result uses this chronology. !(p) This method matches the signature of the functional interface {@link TemporalQuery} allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
Obtains a {@code ChronoZonedDateTime} _in this chronology from an {@code Instant}. !(p) This obtains a zoned date-time with the same instant as that specified.
Obtains an instance of {@code Chronology} from a temporal object. !(p) This obtains a chronology based on the specified temporal. A {@code TemporalAccessor} represents an arbitrary set of date and time information, which this factory converts to an instance of {@code Chronology}. !(p) The conversion will obtain the chronology using {@link TemporalQueries#chronology()}. If the specified temporal object does not have a chronology, {@link IsoChronology} is returned. !(p) This method matches the signature of the functional interface {@link TemporalQuery} allowing it to be used as a query via method reference, {@code Chronology::from}.
Returns the available chronologies. !(p) Each returned {@code 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.
Obtains an instance of {@code Chronology} from a chronology ID or calendar system type. !(p) This returns a chronology based on either the ID or the type. The {@link #getId() chronology ID} uniquely identifies the chronology. The {@link #getCalendarType() calendar system type} is defined by the CLDR specification. !(p) The chronology may be a system chronology or a chronology provided by the application via ServiceLoader configuration. !(p) Since some calendars can be customized, the ID or type typically refers to the customization. For example, the Gregorian calendar can have multiple cutover dates from the Julian, but the lookup only provides the cutover date.
Obtains an instance of {@code Chronology} from a locale. !(p) This returns a {@code Chronology} based on the specified locale, typically returning {@code IsoChronology}. Other calendar systems are only returned if they are explicitly selected within the locale. !(p) The {@link 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. !(p) The {@code 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. !(p) This method finds the desired calendar system _in a manner equivalent to passing "ca" to {@link Locale#getUnicodeLocaleType(string)}. If the "ca" key is not present, then {@code IsoChronology} is returned. !(p) Note that the behavior of this method differs from the older {@link java.util.Calendar#getInstance(Locale)} method. If that method receives a locale of "th_TH" it will return {@code BuddhistCalendar}. By contrast, this method will return {@code 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. !(p) 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 {@code Locale} to the modern and recommended form of "ja-JP-u-ca-japanese". Thus, there is no difference _in behavior between this method and {@code Calendar#getInstance(Locale)}.
A calendar system, used to organize and identify dates. !(p) 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. !(p) 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 {@link ChronoField} and are available for use by any {@code Chronology} implementation: !(pre) LocalDate isoDate = ... ThaiBuddhistDate thaiDate = ... int isoYear = isoDate.get(ChronoField.YEAR); int thaiYear = thaiDate.get(ChronoField.YEAR); </pre> As shown, although the date objects are _in different calendar systems, represented by different {@code Chronology} instances, both can be queried using the same constant on {@code ChronoField}. For a full discussion of the implications of this, see {@link ChronoLocalDate}. In general, the advice is to use the known ISO-based {@code LocalDate}, rather than {@code ChronoLocalDate}. !(p) While a {@code Chronology} object typically uses {@code 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 {@code Chronology} instance may represent a totally different kind of calendar system, such as the Mayan. !(p) In practical terms, the {@code Chronology} instance also acts as a factory. The {@link #of(string)} method allows an instance to be looked up by identifier, while the {@link #ofLocale(Locale)} method allows lookup by locale. !(p) The {@code Chronology} instance provides a set of methods to create {@code ChronoLocalDate} instances. The date classes are used to manipulate specific dates. !(ul) !(li) {@link #dateNow() dateNow()} !(li) {@link #dateNow(Clock) dateNow(clock)} !(li) {@link #dateNow(ZoneId) dateNow(zone)} !(li) {@link #date(int, int, int) date(yearProleptic, month, day)} !(li) {@link #date(Era, int, int, int) date(era, yearOfEra, month, day)} !(li) {@link #dateYearDay(int, int) dateYearDay(yearProleptic, dayOfYear)} !(li) {@link #dateYearDay(Era, int, int) dateYearDay(era, yearOfEra, dayOfYear)} !(li) {@link #date(TemporalAccessor) date(TemporalAccessor)} </ul>
<h3 id="addcalendars">Adding New Calendars</h3> The set of available chronologies can be extended by applications. Adding a new calendar system requires the writing of an implementation of {@code Chronology}, {@code ChronoLocalDate} and {@code Era}. The majority of the logic specific to the calendar system will be _in the {@code ChronoLocalDate} implementation. The {@code Chronology} implementation acts as a factory. !(p) To permit the discovery of additional chronologies, the {@link java.util.ServiceLoader ServiceLoader} is used. A file must be added to the {@code META-INF/services} directory with the name 'hunt.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. !(p) 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.
@implSpec 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