Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package threeten
    Definition Classes
    org
  • package bp

    The main API for dates, times, instants, and durations.

    The main API for dates, times, instants, and durations.

    The classes defined here represent the principal date-time concepts, including instants, durations, dates, times, time-zones and periods. They are based on the ISO calendar system, which is the de facto world calendar following the proleptic Gregorian rules. All the classes are immutable and thread-safe.

    Each date time instance is composed of fields that are conveniently made available by the APIs. For lower level access to the fields refer to the org.threeten.bp.temporal package. Each class includes support for printing and parsing all manner of dates and times. Refer to the org.threeten.bp.format package for customization options.

    The org.threeten.bp.chrono package contains the calendar neutral API. This is intended for use by applications that need to use localized calendars. It is recommended that applications use the ISO-8601 dates and time classes from this package across system boundaries, such as to the database or across the network. The calendar neutral API should be reserved for interactions with users.

    Dates and Times

    org.threeten.bp.Instant is essentially a numeric timestamp. The current Instant can be retrieved from a org.threeten.bp.Clock. This is useful for logging and persistence of a point in time and has in the past been associated with storing the result from java.lang.System#currentTimeMillis().

    org.threeten.bp.LocalDate stores a date without a time. This stores a date like '2010-12-03' and could be used to store a birthday.

    org.threeten.bp.LocalTime stores a time without a date. This stores a time like '11:30' and could be used to store an opening or closing time.

    org.threeten.bp.LocalDateTime stores a date and time. This stores a date-time like '2010-12-03T11:30'.

    org.threeten.bp.OffsetTime stores a time and offset from UTC without a date. This stores a date like '11:30+01:00'. The ZoneOffset is of the form '+01:00'.

    org.threeten.bp.OffsetDateTime stores a date and time and offset from UTC. This stores a date-time like '2010-12-03T11:30+01:00'. This is sometimes found in XML messages and other forms of persistence, but contains less information than a full time-zone.

    org.threeten.bp.ZonedDateTime stores a date and time with a time-zone. This is useful if you want to perform accurate calculations of dates and times taking into account the org.threeten.bp.ZoneId, such as 'Europe/Paris'. Where possible, it is recommended to use a simpler class. The widespread use of time-zones tends to add considerable complexity to an application.

    Duration and Period

    Beyond dates and times, the API also allows the storage of period and durations of time. A org.threeten.bp.Duration is a simple measure of time along the time-line in nanoseconds. A org.threeten.bp.Period expresses an amount of time in units meaningful to humans, such as years or hours.

    Additional value types

    org.threeten.bp.Year stores a year on its own. This stores a single year in isolation, such as '2010'.

    org.threeten.bp.YearMonth stores a year and month without a day or time. This stores a year and month, such as '2010-12' and could be used for a credit card expiry.

    org.threeten.bp.MonthDay stores a month and day without a year or time. This stores a month and day-of-month, such as '--12-03' and could be used to store an annual event like a birthday without storing the year.

    org.threeten.bp.Month stores a month on its own. This stores a single month-of-year in isolation, such as 'DECEMBER'.

    org.threeten.bp.DayOfWeek stores a day-of-week on its own. This stores a single day-of-week in isolation, such as 'TUESDAY'.

    Definition Classes
    threeten
  • package chrono

    Support for calendar systems other than the default ISO.

    Support for calendar systems other than the default ISO.

    The main API is based around the calendar system defined in ISO-8601. This package provides support for alternate systems.

    The supported calendar systems includes:

    -Hijrah calendar -Japanese calendar -Minguo calendar -Thai Buddhist calendar

    It is intended that applications use the main API whenever possible, including code to read and write from a persistent data store, such as a database, and to send dates and times across a network. This package is then used at the user interface level to deal with localized input/output. See ChronoLocalDate for a full discussion of the issues.

    Example

    This example creates and uses a date in a non-ISO calendar system.

            // Print the Thai Buddhist date
            ChronoLocalDate now1 = ThaiBuddhistChronology.INSTANCE.now();
            int day = now1.get(ChronoField.DAY_OF_MONTH);
            int dow = now1.get(ChronoField.DAY_OF_WEEK);
            int month = now1.get(ChronoField.MONTH_OF_YEAR);
            int year = now1.get(ChronoField.YEAR);
            System.out.printf("  Today is %s %s %d-%s-%d%n", now1.getChronology().getId(),
                    dow, day, month, year);
    
            // Enumerate the list of available calendars and print today for each
            Set<String> names = Chronology.getAvailableIds();
            for (String name : names) {
                Chronology<?> chrono = Chronology.of(name);
                ChronoLocalDate<?> date = chrono.now();
                System.out.printf("   %20s: %s%n", chrono.getId(), date.toString());
            }
    
            // Print today's date and the last day of the year for the Thai Buddhist Calendar.
            ChronoLocalDate first = now1
                    .with(ChronoField.DAY_OF_MONTH, 1)
                    .with(ChronoField.MONTH_OF_YEAR, 1);
            ChronoLocalDate last = first
                    .plus(1, ChronoUnit.YEARS)
                    .minus(1, ChronoUnit.DAYS);
            System.out.printf("  %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(),
                    first, last);
    

    Definition Classes
    bp
  • package internal
    Definition Classes
    chrono
  • AbstractChronology
  • ChronoDateImpl
  • ChronoLocalDate
  • ChronoLocalDateTime
  • ChronoLocalDateTimeImpl
  • ChronoPeriod
  • ChronoPeriodImpl
  • ChronoZonedDateTime
  • ChronoZonedDateTimeImpl
  • Chronology
  • Era
  • HijrahChronology
  • HijrahDate
  • HijrahDateConfigurator
  • HijrahEra
  • IsoChronology
  • IsoEra
  • JapaneseChronology
  • JapaneseDate
  • JapaneseEra
  • MinguoChronology
  • MinguoDate
  • MinguoEra
  • Ser
  • ThaiBuddhistChronology
  • ThaiBuddhistDate
  • ThaiBuddhistEra

final class IsoChronology extends Chronology with Serializable

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:

  • era - There are two eras, 'Current Era' (CE) and 'Before Current Era' (BCE).
  • year-of-era - The year-of-era is the same as the proleptic-year for the current CE era. For the BCE era before the ISO epoch the year increases from 1 upwards as time goes backwards.
  • proleptic-year - The proleptic year is the same as the year-of-era for the current era. For the previous era, years have zero, then negative values.
  • month-of-year - There are 12 months in an ISO year, numbered from 1 to 12.
  • day-of-month - There are between 28 and 31 days in each of the ISO month, numbered from 1 to 31. Months 4, 6, 9 and 11 have 30 days, Months 1, 3, 5, 7, 8, 10 and 12 have 31 days. Month 2 has 28 days, or 29 in a leap year.
  • day-of-year - There are 365 days in a standard ISO year and 366 in a leap year. The days are numbered from 1 to 365 or 1 to 366.
  • leap-year - Leap years occur every 4 years, except where the year is divisble by 100 and not divisble by 400.
Specification for implementors

This class is immutable and thread-safe.

Annotations
@SerialVersionUID()
Linear Supertypes
Serializable, Chronology, Ordered[Chronology], Comparable[Chronology], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. IsoChronology
  2. Serializable
  3. Chronology
  4. Ordered
  5. Comparable
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def <(that: Chronology): Boolean
    Definition Classes
    Ordered
  4. def <=(that: Chronology): Boolean
    Definition Classes
    Ordered
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def >(that: Chronology): Boolean
    Definition Classes
    Ordered
  7. def >=(that: Chronology): Boolean
    Definition Classes
    Ordered
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  10. def compare(other: Chronology): Int

    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
    Definition Classes
    Ordered → Comparable
  12. def date(temporal: TemporalAccessor): LocalDate

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

    temporal

    the date-time object to convert, not null

    returns

    the ISO local date, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  13. def date(prolepticYear: Int, month: Int, dayOfMonth: Int): LocalDate

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

    prolepticYear

    the ISO proleptic-year

    month

    the ISO month-of-year

    dayOfMonth

    the ISO day-of-month

    returns

    the ISO local date, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  14. def date(era: Era, yearOfEra: Int, month: Int, dayOfMonth: Int): LocalDate

    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.

    era

    the ISO era, not null

    yearOfEra

    the ISO year-of-era

    month

    the ISO month-of-year

    dayOfMonth

    the ISO day-of-month

    returns

    the ISO local date, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  15. def dateEpochDay(epochDay: Long): LocalDate

    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

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  16. def dateNow(clock: Clock): LocalDate

    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.

    clock

    the clock to use, not null

    returns

    the current ISO local date, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  17. def dateNow(zone: ZoneId): LocalDate

    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.

    zone

    the zone ID to use, not null

    returns

    the current ISO local date using the system clock, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  18. def dateNow: LocalDate

    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.

    returns

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

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  19. def dateYearDay(prolepticYear: Int, dayOfYear: Int): LocalDate

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

    prolepticYear

    the ISO proleptic-year

    dayOfYear

    the ISO day-of-year

    returns

    the ISO local date, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  20. def dateYearDay(era: Era, yearOfEra: Int, dayOfYear: Int): LocalDate

    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.

    era

    the ISO era, not null

    yearOfEra

    the ISO year-of-era

    dayOfYear

    the ISO day-of-year

    returns

    the ISO local date, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date

  21. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. def equals(obj: Any): Boolean

    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
  23. def eraOf(eraValue: Int): IsoEra

    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

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the era

  24. def eras: List[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.

    returns

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

    Definition Classes
    IsoChronologyChronology
  25. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  26. def getCalendarType: String

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

    returns

    the calendar system type - 'iso8601'

    Definition Classes
    IsoChronologyChronology
    See also

    #getId()

  27. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  28. def getDisplayName(style: TextStyle, locale: Locale): String

    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

    Definition Classes
    Chronology
  29. def getId: String

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

    returns

    the chronology ID - 'ISO'

    Definition Classes
    IsoChronologyChronology
    See also

    #getCalendarType()

  30. def hashCode(): Int

    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
  31. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  32. def isLeapYear(prolepticYear: Long): Boolean

    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.

    prolepticYear

    the ISO proleptic year to check

    returns

    true if the year is leap, false otherwise

    Definition Classes
    IsoChronologyChronology
  33. def localDateTime(temporal: TemporalAccessor): LocalDateTime

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

    temporal

    the date-time object to convert, not null

    returns

    the ISO local date-time, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date-time

  34. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  35. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  36. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  37. def period(years: Int, months: Int, days: Int): ChronoPeriod

    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

    Definition Classes
    Chronology
  38. def prolepticYear(era: Era, yearOfEra: Int): Int

    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

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

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

    DateTimeException if unable to convert

  39. def range(field: ChronoField): ValueRange

    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

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if the range for the field cannot be obtained

  40. def resolveDate(fieldValues: Map[TemporalField, Long], resolverStyle: ResolverStyle): LocalDate

    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

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

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

  41. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  42. def toString(): String

    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
  43. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  46. def zonedDateTime(instant: Instant, zone: ZoneId): ZonedDateTime

    Obtains an ISO zoned date-time from an instant.

    Obtains an ISO zoned date-time from an instant.

    This is equivalent to ZoneId).

    instant

    the instant to convert, not null

    zone

    the zone to use, not null

    returns

    the ISO zoned date-time, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date-time

  47. def zonedDateTime(temporal: TemporalAccessor): ZonedDateTime

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

    temporal

    the date-time object to convert, not null

    returns

    the ISO zoned date-time, not null

    Definition Classes
    IsoChronologyChronology
    Exceptions thrown

    DateTimeException if unable to create the date-time

Inherited from Serializable

Inherited from Chronology

Inherited from Ordered[Chronology]

Inherited from Comparable[Chronology]

Inherited from AnyRef

Inherited from Any

Ungrouped