Trait/Object

org.threeten.bp.chrono

Chronology

Related Docs: object Chronology | package chrono

Permalink

trait Chronology extends Ordered[Chronology]

A calendar system, used to organize and identify dates.

The main date and time API is built on the ISO calendar system. This class 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 availalbe for use by any Chronology implementation:

val isoDate: LocalDate = ...
val thaiDate: ChronoLocalDate[ThaiBuddhistChrono] = ...
val isoYear: Int = isoDate.get(ChronoField.YEAR);
val thaiYear: Int = 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 ChronoLocalDate. The Chronology subclass 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 'org.threeten.bp.chrono.Chrono' 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 Unicode Locale Data Markup Language (LDML) specification then that calendar type should also be specified.

Specification for implementors

This class 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.

Linear Supertypes
Ordered[Chronology], Comparable[Chronology], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Chronology
  2. Ordered
  3. Comparable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def date(temporal: TemporalAccessor): ChronoLocalDate

    Permalink

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

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

    This creates a date in this chronology based on the specified TemporalAccessor.

    The standard mechanism for conversion between date types is the local epoch-day field.

    temporal

    the temporal object to convert, not null

    returns

    the local date in this chronology, not null

    Exceptions thrown

    DateTimeException if unable to create the date

  2. abstract def date(prolepticYear: Int, month: Int, dayOfMonth: Int): ChronoLocalDate

    Permalink

    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 the proleptic-year, month-of-year and day-of-month fields.

    prolepticYear

    the chronology proleptic-year

    month

    the chronology month-of-year

    dayOfMonth

    the chronology day-of-month

    returns

    the local date in this chronology, not null

    Exceptions thrown

    DateTimeException if unable to create the date

  3. abstract def dateEpochDay(epochDay: Long): ChronoLocalDate

    Permalink

    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.

    epochDay

    the epoch day

    returns

    the local date in this chronology, not null

    Exceptions thrown

    DateTimeException if unable to create the date

  4. abstract def dateYearDay(prolepticYear: Int, dayOfYear: Int): ChronoLocalDate

    Permalink

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

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

    prolepticYear

    the chronology proleptic-year

    dayOfYear

    the chronology day-of-year

    returns

    the local date in this chronology, not null

    Exceptions thrown

    DateTimeException if unable to create the date

  5. abstract def eraOf(eraValue: Int): Era

    Permalink

    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.

    eraValue

    the era value

    returns

    the calendar system era, not null

    Exceptions thrown

    DateTimeException if unable to create the era

  6. abstract def eras: List[Era]

    Permalink

    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.

    returns

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

  7. abstract def getCalendarType: String

    Permalink

    Gets the calendar type of the underlying calendar system.

    Gets the calendar type of the underlying calendar system.

    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'.

    returns

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

    See also

    #getId()

  8. abstract def getId: String

    Permalink

    Gets the ID of the chronology.

    Gets the ID of the chronology.

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

    returns

    the chronology ID, not null

    See also

    #getCalendarType()

  9. abstract def isLeapYear(prolepticYear: Long): Boolean

    Permalink

    Checks if the specified year is a leap year.

    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.
    prolepticYear

    the proleptic-year to check, not validated for range

    returns

    true if the year is a leap year

  10. abstract def prolepticYear(era: Era, yearOfEra: Int): Int

    Permalink

    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.

    era

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

    yearOfEra

    the chronology year-of-era

    returns

    the proleptic-year

    Exceptions thrown

    ClassCastException if the { @code era} is not of the correct type for the chronology

    DateTimeException if unable to convert

  11. abstract def range(field: ChronoField): ValueRange

    Permalink

    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.

    field

    the field to get the range for, not null

    returns

    the range of valid values for the field, not null

    Exceptions thrown

    DateTimeException if the range for the field cannot be obtained

  12. abstract def resolveDate(fieldValues: Map[TemporalField, Long], resolverStyle: ResolverStyle): ChronoLocalDate

    Permalink

    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.

    fieldValues

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

    resolverStyle

    the requested type of resolve, not null

    returns

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

    Exceptions thrown

    DateTimeException if the date cannot be resolved, typically because of a conflict in the input data

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def <(that: Chronology): Boolean

    Permalink
    Definition Classes
    Ordered
  4. def <=(that: Chronology): Boolean

    Permalink
    Definition Classes
    Ordered
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. def >(that: Chronology): Boolean

    Permalink
    Definition Classes
    Ordered
  7. def >=(that: Chronology): Boolean

    Permalink
    Definition Classes
    Ordered
  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def compare(other: Chronology): Int

    Permalink

    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.

    other

    the other chronology to compare to, not null

    returns

    the comparator value, negative if less, positive if greater

    Definition Classes
    Chronology → Ordered
  11. def compareTo(that: Chronology): Int

    Permalink
    Definition Classes
    Ordered → Comparable
  12. def date(era: Era, yearOfEra: Int, month: Int, dayOfMonth: Int): ChronoLocalDate

    Permalink

    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 era, year-of-era, month-of-year and day-of-month fields.

    era

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

    yearOfEra

    the chronology year-of-era

    month

    the chronology month-of-year

    dayOfMonth

    the chronology day-of-month

    returns

    the local date in this chronology, not null

    Exceptions thrown

    ClassCastException if the { @code era} is not of the correct type for the chronology

    DateTimeException if unable to create the date

  13. def dateNow(clock: Clock): ChronoLocalDate

    Permalink

    Obtains the current local date in this chronology from the specified 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.

    clock

    the clock to use, not null

    returns

    the current local date, not null

    Exceptions thrown

    DateTimeException if unable to create the date

  14. def dateNow(zone: ZoneId): ChronoLocalDate

    Permalink

    Obtains the current local date in this chronology from the system clock in the specified time-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.

    zone

    the zone ID to use, not null

    returns

    the current local date using the system clock, not null

    Exceptions thrown

    DateTimeException if unable to create the date

  15. def dateNow: ChronoLocalDate

    Permalink

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

    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.

    This implementation uses #dateNow(Clock).

    returns

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

    Exceptions thrown

    DateTimeException if unable to create the date

  16. def dateYearDay(era: Era, yearOfEra: Int, dayOfYear: Int): ChronoLocalDate

    Permalink

    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 era, year-of-era and day-of-year fields.

    era

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

    yearOfEra

    the chronology year-of-era

    dayOfYear

    the chronology day-of-year

    returns

    the local date in this chronology, not null

    Exceptions thrown

    ClassCastException if the { @code era} is not of the correct type for the chronology

    DateTimeException if unable to create the date

  17. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. def equals(obj: Any): Boolean

    Permalink

    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).

    obj

    the object to check, null returns false

    returns

    true if this is equal to the other chronology

    Definition Classes
    Chronology → AnyRef → Any
  19. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  21. def getDisplayName(style: TextStyle, locale: Locale): String

    Permalink

    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.

    style

    the style of the text required, not null

    locale

    the locale to use, not null

    returns

    the text value of the chronology, not null

  22. def hashCode(): Int

    Permalink

    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.

    returns

    a suitable hash code

    Definition Classes
    Chronology → AnyRef → Any
  23. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  24. def localDateTime(temporal: TemporalAccessor): ChronoLocalDateTime[_]

    Permalink

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

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

    This creates a date-time in this chronology based on the specified TemporalAccessor.

    The date of the date-time should be equivalent to that obtained by calling #date(TemporalAccessor). The standard mechanism for conversion between time types is the nano-of-day field.

    temporal

    the temporal object to convert, not null

    returns

    the local date-time in this chronology, not null

    Exceptions thrown

    DateTimeException if unable to create the date-time

  25. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. def period(years: Int, months: Int, days: Int): ChronoPeriod

    Permalink

    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.

    years

    the number of years, may be negative

    months

    the number of years, may be negative

    days

    the number of years, may be negative

    returns

    the period in terms of this chronology, not null

  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  30. def toString(): String

    Permalink

    Outputs this chronology as a String, using the ID.

    Outputs this chronology as a String, using the ID.

    returns

    a string representation of this chronology, not null

    Definition Classes
    Chronology → AnyRef → Any
  31. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def zonedDateTime(instant: Instant, zone: ZoneId): ChronoZonedDateTime[_ <: ChronoLocalDate]

    Permalink

    Obtains a zoned date-time in this chronology from an Instant.

    Obtains a zoned date-time in this chronology from an Instant.

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

    instant

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

    zone

    the time-zone, not null

    returns

    the zoned date-time, not null

    Exceptions thrown

    DateTimeException if the result exceeds the supported range

  35. def zonedDateTime(temporal: TemporalAccessor): ChronoZonedDateTime[_]

    Permalink

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

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

    This creates a date-time in this chronology based on the specified TemporalAccessor.

    This should obtain a ZoneId using ZoneId#from(TemporalAccessor). The date-time should be obtained by obtaining an Instant. If that fails, the local date-time should be used.

    temporal

    the temporal object to convert, not null

    returns

    the zoned date-time in this chronology, not null

    Exceptions thrown

    DateTimeException if unable to create the date-time

Inherited from Ordered[Chronology]

Inherited from Comparable[Chronology]

Inherited from AnyRef

Inherited from Any

Ungrouped