org.threeten.bp

temporal

package temporal

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:

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. temporal
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. final class ChronoField extends Enum[ChronoField] with TemporalField

  2. final class ChronoUnit extends Enum[ChronoUnit] with TemporalUnit

  3. trait Temporal extends TemporalAccessor

    Framework-level interface defining read-write access to a temporal object, such as a date, time, offset or some combination of these.

  4. trait TemporalAccessor extends AnyRef

    Framework-level interface defining read-only access to a temporal object, such as a date, time, offset or some combination of these.

  5. trait TemporalAdjuster extends AnyRef

    Strategy for adjusting a temporal object.

  6. trait TemporalAmount extends AnyRef

    Framework-level interface defining an amount of time, such as "6 hours", "8 days" or "2 years and 3 months".

  7. trait TemporalField extends AnyRef

    A field of date-time, such as month-of-year or hour-of-minute.

  8. trait TemporalQuery[+R] extends AnyRef

    Strategy for querying a temporal object.

  9. trait TemporalUnit extends AnyRef

    A unit of date-time, such as Days or Hours.

  10. class UnsupportedTemporalTypeException extends DateTimeException

    An exception that indicates a type is unsupported.

  11. final class ValueRange extends Serializable

    The range of valid values for a date-time field.

  12. final class WeekFields extends Serializable

    Localized definitions of the day-of-week, week-of-month and week-of-year fields.

Value Members

  1. object ChronoField extends Serializable

    A standard set of fields.

  2. object ChronoUnit extends Serializable

    A standard set of date periods units.

  3. object IsoFields

    Fields and units specific to the ISO-8601 calendar system, including quarter-of-year and week-based-year.

  4. object JulianFields

    A set of date fields that provide access to Julian Days.

  5. object TemporalAdjusters

    Common implementations of TemporalAdjuster.

  6. object TemporalQueries

    Common implementations of TemporalQuery.

  7. object ValueRange extends Serializable

    Annotations
    @SerialVersionUID( 7317881728594519368L )
  8. object WeekFields extends Serializable

    Annotations
    @SerialVersionUID( 1177360819670808121L )

Inherited from AnyRef

Inherited from Any

Ungrouped