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

object Chronology

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Chronology
  2. AnyRef
  3. 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. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def from(temporal: TemporalAccessor): Chronology

    Obtains an instance of Chronology from a temporal object.

    Obtains an instance of Chronology from a temporal object.

    A TemporalAccessor represents some form of date and time information. This factory converts the arbitrary temporal object to an instance of Chronology. If the specified temporal object does not have a chronology, IsoChronology is returned.

    The conversion will obtain the chronology using TemporalQueries#chronology().

    This method matches the signature of the functional interface TemporalQuery allowing it to be used in queries via method reference, Chrono::from.

    temporal

    the temporal to convert, not null

    returns

    the chronology, not null

    Exceptions thrown

    DateTimeException if unable to convert to an { @code Chronology}

  10. def getAvailableChronologies: Set[Chronology]

    Returns the available chronologies.

    Returns the available chronologies.

    Each returned Chronology is available for use in the system.

    returns

    the independent, modifiable set of the available chronology IDs, not null

  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. def of(id: String): Chronology

    Obtains an instance of Chronology from a chronology ID or calendar system type.

    Obtains an instance of Chronology from a chronology ID or calendar system type.

    This returns a chronology based on either the ID or the type. The chronology ID uniquely identifies the chronology. The calendar system type is defined by the LDML specification.

    The chronology may be a system chronology or a chronology provided by the application via ServiceLoader configuration.

    Since some calendars can be customized, the ID or type typically refers to the default customization. For example, the Gregorian calendar can have multiple cutover dates from the Julian, but the lookup only provides the default cutover date.

    id

    the chronology ID or calendar system type, not null

    returns

    the chronology with the identifier requested, not null

    Exceptions thrown

    DateTimeException if the chronology cannot be found

  18. def ofLocale(locale: Locale): Chronology

    Obtains an instance of Chronology from a locale.

    Obtains an instance of Chronology from a locale.

    This returns a Chronology based on the specified locale, typically returning IsoChronology. Other calendar systems are only returned if they are explicitly selected within the locale.

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

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

    This method finds the desired calendar system by in a manner equivalent to passing "ca" to Locale#getUnicodeLocaleType(String). If the "ca" key is not present, then IsoChronology is returned.

    Note that the behavior of this method differs from the older java.util.Calendar#getInstance(Locale) method. If that method receives a locale of "th_TH" it will return BuddhistCalendar. By contrast, this method will return 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.

    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 Locale to the modern and recommended form of "ja-JP-u-ca-japanese". Thus, there is no difference in behavior between this method and Calendar#getInstance(Locale).

    locale

    the locale to use to obtain the calendar system, not null

    returns

    the calendar system associated with the locale, not null

    Exceptions thrown

    DateTimeException if the locale-specified calendar cannot be found

  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped