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 temporal

    Access to date and time using fields and units.

    Access to date and time using fields and units.

    This package expands on the base package to provide additional functionality for more powerful use cases. Support is included for:

    • Units of date-time, such as years, months, days and hours
    • Fields of date-time, such as month-of-year, day-of-week or hour-of-day
    • Date-time adjustment functions
    • Different definitions of weeks

    Fields and Units

    Dates and times are expressed in terms of fields and units. A unit is used to measure an amount of time, such as years, days or minutes. All units implement org.threeten.bp.temporal.TemporalUnit. The set of well known units is defined in org.threeten.bp.temporal.ChronoUnit, for example, org.threeten.bp.temporal.ChronoUnit#DAYS. The unit interface is designed to allow applications to add their own units.

    A field is used to express part of a larger date-time, such as year, month-of-year or second-of-minute. All fields implement org.threeten.bp.temporal.TemporalField. The set of well known fields are defined in org.threeten.bp.temporal.ChronoField, for example, org.threeten.bp.temporal.ChronoField#HOUR_OF_DAY. An additional fields are defined by org.threeten.bp.temporal.JulianFields. The field interface is designed to allow applications to add their own fields.

    This package provides tools that allow the units and fields of date and time to be accessed in a general way most suited for frameworks. org.threeten.bp.temporal.Temporal provides the abstraction for date time types that support fields. Its methods support getting the value of a field, creating a new date time with the value of a field modified, and extracting another date time type, typically used to extract the offset or time-zone.

    One use of fields in application code is to retrieve fields for which there is no convenience method. For example, getting the day-of-month is common enough that there is a method on LocalDate called getDayOfMonth(). However for more unusual fields it is necessary to use the field. For example, date.get(ChronoField.ALIGNED_WEEK_OF_MONTH). The fields also provide access to the range of valid values.

    Adjustment

    A key part of the date-time problem space is adjusting a date to a new, related value, such as the "last day of the month", or "next Wednesday". These are modeled as functions that adjust a base date-time. The functions implement org.threeten.bp.temporal.TemporalAdjuster and operate on org.threeten.bp.temporal.Temporal. A set of common functions are provided in org.threeten.bp.temporal.TemporalAdjusters. For example, to find the first occurrence of a day-of-week after a given date, use org.threeten.bp.temporal.TemporalAdjusters#next(DayOfWeek), such as date.with(next(MONDAY)).

    Weeks

    Different locales have different definitions of the week. For example, in Europe the week typically starts on a Monday, while in the US it starts on a Sunday. The org.threeten.bp.temporal.WeekFields class models this distinction.

    The ISO calendar system defines an additional week-based division of years. This defines a year based on whole Monday to Monday weeks. This is modeled in org.threeten.bp.temporal.IsoFields.

    Definition Classes
    bp
  • ChronoField
  • ChronoUnit
  • IsoFields
  • JulianFields
  • Temporal
  • TemporalAccessor
  • TemporalAdjuster
  • TemporalAdjusters
  • TemporalAmount
  • TemporalField
  • TemporalQueries
  • TemporalQuery
  • TemporalUnit
  • UnsupportedTemporalTypeException
  • ValueRange
  • WeekFields
o

org.threeten.bp.temporal

TemporalQueries

object TemporalQueries

Common implementations of TemporalQuery.

This class provides common implementations of TemporalQuery. These queries are primarily used as optimizations, allowing the internals of other objects to be extracted effectively. Note that application code can also use the from(TemporalAccessor) method on most temporal objects as a method reference matching the query interface, such as LocalDate::from and ZoneId::from.

There are two equivalent ways of using a TemporalQuery. The first is to invoke the method on the interface directly. The second is to use TemporalAccessor#query(TemporalQuery):

// these two lines are equivalent, but the second approach is recommended
dateTime = query.queryFrom(dateTime);
dateTime = dateTime.query(query);
It is recommended to use the second approach, query(TemporalQuery), as it is a lot clearer to read in code.

Specification for implementors

This is a thread-safe utility class. All returned adjusters are immutable and thread-safe.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TemporalQueries
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

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. lazy val chronology: TemporalQuery[Chronology]

    A query for the Chronology.

    A query for the Chronology.

    This queries a TemporalAccessor for the chronology. If the target TemporalAccessor represents a date, or part of a date, then it should return the chronology that the date is expressed in. As a result of this definition, objects only representing time, such as LocalTime, will return null.

    The result from JDK classes implementing TemporalAccessor is as follows:
    LocalDate returns IsoChronology.INSTANCE
    LocalTime returns null (does not represent a date)
    LocalDateTime returns IsoChronology.INSTANCE
    ZonedDateTime returns IsoChronology.INSTANCE
    OffsetTime returns null (does not represent a date)
    OffsetDateTime returns IsoChronology.INSTANCE
    ChronoLocalDate returns the associated chronology
    ChronoLocalDateTime returns the associated chronology
    ChronoZonedDateTime returns the associated chronology
    Era returns the associated chronology
    DayOfWeek returns null (shared across chronologies)
    Month returns IsoChronology.INSTANCE
    Year returns IsoChronology.INSTANCE
    YearMonth returns IsoChronology.INSTANCE
    MonthDay returns null IsoChronology.INSTANCE
    ZoneOffset returns null (does not represent a date)
    Instant returns null (does not represent a date)

    The method Chronology#from(TemporalAccessor) can be used as a TemporalQuery via a method reference, Chrono::from. That method is equivalent to this query, except that it throws an exception if a chronology cannot be obtained.

    returns

    a query that can obtain the chronology of a temporal, not null

  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. lazy val localDate: TemporalQuery[LocalDate]

    A query for LocalDate returning null if not found.

    A query for LocalDate returning null if not found.

    This returns a TemporalQuery that can be used to query a temporal object for the local date. The query will return null if the temporal object cannot supply a local date.

    The query implementation examines the EPOCH_DAY field and uses it to create a LocalDate.

    returns

    a query that can obtain the date of a temporal, not null

  14. lazy val localTime: TemporalQuery[LocalTime]

    A query for LocalTime returning null if not found.

    A query for LocalTime returning null if not found.

    This returns a TemporalQuery that can be used to query a temporal object for the local time. The query will return null if the temporal object cannot supply a local time.

    The query implementation examines the NANO_OF_DAY field and uses it to create a LocalTime.

    returns

    a query that can obtain the date of a temporal, not null

  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. lazy val offset: TemporalQuery[ZoneOffset]

    A query for ZoneOffset returning null if not found.

    A query for ZoneOffset returning null if not found.

    This returns a TemporalQuery that can be used to query a temporal object for the offset. The query will return null if the temporal object cannot supply an offset.

    The query implementation examines the OFFSET_SECONDS field and uses it to create a ZoneOffset.

    returns

    a query that can obtain the offset of a temporal, not null

  19. lazy val precision: TemporalQuery[TemporalUnit]

    A query for the smallest supported unit.

    A query for the smallest supported unit.

    This queries a TemporalAccessor for the time precision. If the target TemporalAccessor represents a consistent or complete date-time, date or time then this must return the smallest precision actually supported. Note that fields such as NANO_OF_DAY and NANO_OF_SECOND are defined to always return ignoring the precision, thus this is the only way to find the actual smallest supported unit. For example, were GregorianCalendar to implement TemporalAccessor it would return a precision of MILLIS.

    The result from JDK classes implementing TemporalAccessor is as follows:
    LocalDate returns DAYS
    LocalTime returns NANOS
    LocalDateTime returns NANOS
    ZonedDateTime returns NANOS
    OffsetTime returns NANOS
    OffsetDateTime returns NANOS
    ChronoLocalDate returns DAYS
    ChronoLocalDateTime returns NANOS
    ChronoZonedDateTime returns NANOS
    Era returns ERAS
    DayOfWeek returns DAYS
    Month returns MONTHS
    Year returns YEARS
    YearMonth returns MONTHS
    MonthDay returns null (does not represent a complete date or time)
    ZoneOffset returns null (does not represent a date or time)
    Instant returns NANOS

    returns

    a query that can obtain the precision of a temporal, not null

  20. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  23. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  24. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  25. lazy val zone: TemporalQuery[ZoneId]

    A lenient query for the ZoneId, falling back to the ZoneOffset.

    A lenient query for the ZoneId, falling back to the ZoneOffset.

    This queries a TemporalAccessor for the zone. It first tries to obtain the zone, using #zoneId(). If that is not found it tries to obtain the #offset().

    In most cases, applications should use this query rather than #zoneId().

    This query examines the offset-seconds field and uses it to create a ZoneOffset.

    The method ZoneId#from(TemporalAccessor) can be used as a TemporalQuery via a method reference, ZoneId::from. That method is equivalent to this query, except that it throws an exception if a zone cannot be obtained.

    returns

    a query that can obtain the zone ID or offset of a temporal, not null

  26. lazy val zoneId: TemporalQuery[ZoneId]

    A strict query for the ZoneId.

    A strict query for the ZoneId.

    This queries a TemporalAccessor for the zone. The zone is only returned if the date-time conceptually contains a ZoneId. It will not be returned if the date-time only conceptually has an ZoneOffset. Thus a ZonedDateTime will return the result of getZone(), but an OffsetDateTime will return null.

    In most cases, applications should use #ZONE as this query is too strict.

    The result from JDK classes implementing TemporalAccessor is as follows:
    LocalDate returns null
    LocalTime returns null
    LocalDateTime returns null
    ZonedDateTime returns the associated zone
    OffsetTime returns null
    OffsetDateTime returns null
    ChronoLocalDate returns null
    ChronoLocalDateTime returns null
    ChronoZonedDateTime returns the associated zone
    Era returns null
    DayOfWeek returns null
    Month returns null
    Year returns null
    YearMonth returns null
    MonthDay returns null
    ZoneOffset returns null
    Instant returns null

    returns

    a query that can obtain the zone ID of a temporal, not null

Inherited from AnyRef

Inherited from Any

Ungrouped