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 format

    Provides classes to print and parse dates and times.

    Provides classes to print and parse dates and times.

    Printing and parsing is based around the DateTimeFormatter class. That class contains common formatters and factory methods. The DateTimeFormatterBuilder class is available for advanced and complex use cases.

    Localization occurs by calling withLocale(Locale) on the formatter. Further customization is possible using DecimalStyle.

    Definition Classes
    bp
  • 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
  • package zone

    Support for time-zones and their rules.

    Support for time-zones and their rules.

    Daylight Saving Time and Time-Zones are concepts used by Governments to alter local time. This package provides support for time-zones, their rules and the resulting gaps and overlaps in the local time-line typically caused by Daylight Saving Time.

    Definition Classes
    bp
p

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:

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

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

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.

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

    This is the base interface type for date, time and offset objects that are complete enough to be manipulated using plus and minus. It is implemented by those classes that can provide and manipulate information as fields or queries. See TemporalAccessor for the read-only version of this interface.

    Most date and time information can be represented as a number. These are modeled using TemporalField with the number held using a long to handle large values. Year, month and day-of-month are simple examples of fields, but they also include instant and offsets. See ChronoField for the standard set of fields.

    Two pieces of date/time information cannot be represented by numbers, the chronology and the time-zone. These can be accessed via queries using the static methods defined on TemporalQueries.

    This interface is a framework-level interface that should not be widely used in application code. Instead, applications should create and pass around instances of concrete types, such as LocalDate. There are many reasons for this, part of which is that implementations of this interface may be in calendar systems other than ISO. See ChronoLocalDate for a fuller discussion of the issues.

    When to implement

    A class should implement this interface if it meets three criteria:

    • it provides access to date/time/offset information, as per TemporalAccessor
    • the set of fields are contiguous from the largest to the smallest
    • the set of fields are complete, such that no other field is needed to define the valid range of values for the fields that are represented

    Four examples make this clear:

    • LocalDate implements this interface as it represents a set of fields that are contiguous from days to forever and require no external information to determine the validity of each date. It is therefore able to implement plus/minus correctly.
    • LocalTime implements this interface as it represents a set of fields that are contiguous from nanos to within days and require no external information to determine validity. It is able to implement plus/minus correctly, by wrapping around the day.
    • MonthDay, the combination of month-of-year and day-of-month, does not implement this interface. While the combination is contiguous, from days to months within years, the combination does not have sufficient information to define the valid range of values for day-of-month. As such, it is unable to implement plus/minus correctly.
    • The combination day-of-week and day-of-month ("Friday the 13th") should not implement this interface. It does not represent a contiguous set of fields, as days to weeks overlaps days to months.
    Specification for implementors

    This interface places no restrictions on the mutability of implementations, however immutability is strongly recommended. All implementations must be Comparable.

  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.

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

    This is the base interface type for date, time and offset objects. It is implemented by those classes that can provide information as fields or queries.

    Most date and time information can be represented as a number. These are modeled using TemporalField with the number held using a long to handle large values. Year, month and day-of-month are simple examples of fields, but they also include instant and offsets. See ChronoField for the standard set of fields.

    Two pieces of date/time information cannot be represented by numbers, the chronology and the time-zone. These can be accessed via queries using the static methods defined on TemporalQueries.

    A sub-interface, Temporal, extends this definition to one that also supports adjustment and manipulation on more complete temporal objects.

    This interface is a framework-level interface that should not be widely used in application code. Instead, applications should create and pass around instances of concrete types, such as LocalDate. There are many reasons for this, part of which is that implementations of this interface may be in calendar systems other than ISO. See ChronoLocalDate for a fuller discussion of the issues.

    Specification for implementors

    This interface places no restrictions on the mutability of implementations, however immutability is strongly recommended.

  5. trait TemporalAdjuster extends AnyRef

    Strategy for adjusting a temporal object.

    Strategy for adjusting a temporal object.

    Adjusters are a key tool for modifying temporal objects. They exist to externalize the process of adjustment, permitting different approaches, as per the strategy design pattern. Examples might be an adjuster that sets the date avoiding weekends, or one that sets the date to the last day of the month.

    There are two equivalent ways of using a TemporalAdjuster. The first is to invoke the method on this interface directly. The second is to use Temporal#with(TemporalAdjuster):

    // these two lines are equivalent, but the second approach is recommended
    temporal = thisAdjuster.adjustInto(temporal);
    temporal = temporal.with(thisAdjuster);
    
    It is recommended to use the second approach, with(TemporalAdjuster), as it is a lot clearer to read in code.

    See TemporalAdjusters for a standard set of adjusters, including finding the last day of the month. Adjusters may also be defined by applications.

    Specification for implementors

    This interface places no restrictions on the mutability of implementations, however immutability is strongly recommended.

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

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

    This is the base interface type for amounts of time. An amount is distinct from a date or time-of-day in that it is not tied to any specific point on the time-line.

    The amount can be thought of as a Map of TemporalUnit to long, exposed via #getUnits() and #get(TemporalUnit). A simple case might have a single unit-value pair, such as "6 hours". A more complex case may have multiple unit-value pairs, such as "7 years, 3 months and 5 days".

    There are two common implementations. Period is a date-based implementation, storing years, months and days. Duration is a time-based implementation, storing seconds and nanoseconds, but providing some access using other duration based units such as minutes, hours and fixed 24-hour days.

    This interface is a framework-level interface that should not be widely used in application code. Instead, applications should create and pass around instances of concrete types, such as Period and Duration.

    Specification for implementors

    This interface places no restrictions on the mutability of implementations, however immutability is strongly recommended.

  7. trait TemporalField extends AnyRef

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

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

    Date and time is expressed using fields which partition the time-line into something meaningful for humans. Implementations of this interface represent those fields.

    The most commonly used units are defined in ChronoField. Further fields are supplied in IsoFields, WeekFields and JulianFields. Fields can also be written by application code by implementing this interface.

    The field works using double dispatch. Client code calls methods on a date-time like LocalDateTime which check if the field is a ChronoField. If it is, then the date-time must handle it. Otherwise, the method call is re-dispatched to the matching method in this interface.

    Specification for implementors

    This interface must be implemented with care to ensure other classes operate correctly. All implementations that can be instantiated must be final, immutable and thread-safe. Implementations should be Serializable where possible. An enum is as effective implementation choice.

  8. trait TemporalQuery[+R] extends AnyRef

    Strategy for querying a temporal object.

    Strategy for querying a temporal object.

    Queries are a key tool for extracting information from temporal objects. They exist to externalize the process of querying, permitting different approaches, as per the strategy design pattern. Examples might be a query that checks if the date is the day before February 29th in a leap year, or calculates the number of days to your next birthday.

    The TemporalField interface provides another mechanism for querying temporal objects. That interface is limited to returning a long. By contrast, queries can return any type.

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

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

    The most common implementations are method references, such as LocalDate::from and ZoneId::from. Further implementations are on TemporalQueries. Queries may also be defined by applications.

    Specification for implementors

    This interface places no restrictions on the mutability of implementations, however immutability is strongly recommended.

  9. trait TemporalUnit extends AnyRef

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

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

    Measurement of time is built on units, such as years, months, days, hours, minutes and seconds. Implementations of this interface represent those units.

    An instance of this interface represents the unit itself, rather than an amount of the unit. See Period for a class that represents an amount in terms of the common units.

    The most commonly used units are defined in ChronoUnit. Further units are supplied in IsoFields. Units can also be written by application code by implementing this interface.

    The unit works using double dispatch. Client code calls methods on a date-time like LocalDateTime which check if the unit is a ChronoUnit. If it is, then the date-time must handle it. Otherwise, the method call is re-dispatched to the matching method in this interface.

    Specification for implementors

    This interface must be implemented with care to ensure other classes operate correctly. All implementations that can be instantiated must be final, immutable and thread-safe. It is recommended to use an enum where possible.

  10. class UnsupportedTemporalTypeException extends DateTimeException

    An exception that indicates a type is unsupported.

    An exception that indicates a type is unsupported.

    Specification for implementors

    This class is intended for use in a single thread.

    Constructs a new date-time exception with the specified message and cause.

  11. final class ValueRange extends Serializable

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

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

    All TemporalField instances have a valid range of values. For example, the ISO day-of-month runs from 1 to somewhere between 28 and 31. This class captures that valid range.

    It is important to be aware of the limitations of this class. Only the minimum and maximum values are provided. It is possible for there to be invalid values within the outer range. For example, a weird field may have valid values of 1, 2, 4, 6, 7, thus have a range of '1 - 7', despite that fact that values 3 and 5 are invalid.

    Instances of this class are not tied to a specific field.

    Specification for implementors

    This class is immutable and thread-safe.

  12. final class WeekFields extends Serializable

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

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

    A standard week is seven days long, but cultures have different definitions for some other aspects of a week. This class represents the definition of the week, for the purpose of providing TemporalField instances.

    WeekFields provides three fields, #dayOfWeek(), #weekOfMonth(), and #weekOfYear() that provide access to the values from any temporal object.

    The computations for day-of-week, week-of-month, and week-of-year are based on the proleptic-year, month-of-year, day-of-month, and ISO day-of-week which are based on the epoch-day and the chronology. The values may not be aligned with the year-of-Era depending on the Chronology. A week is defined by:

    • The first day-of-week. For example, the ISO-8601 standard considers Monday to be the first day-of-week.
    • The minimal number of days in the first week. For example, the ISO-8601 standard counts the first week as needing at least 4 days.

    Together these two values allow a year or month to be divided into weeks.

    Week of Month

    One field is used: week-of-month. The calculation ensures that weeks never overlap a month boundary. The month is divided into periods where each period starts on the defined first day-of-week. The earliest period is referred to as week 0 if it has less than the minimal number of days and week 1 if it has at least the minimal number of days.

    Examples of WeekFields
    DateDay-of-week First day: Monday
    Minimal days: 4
    First day: Monday
    Minimal days: 5
    2008-12-31Wednesday Week 5 of December 2008Week 5 of December 2008
    2009-01-01Thursday Week 1 of January 2009Week 0 of January 2009
    2009-01-04Sunday Week 1 of January 2009Week 0 of January 2009
    2009-01-05Monday Week 2 of January 2009Week 1 of January 2009
    === Week of Year === One field is used: week-of-year. The calculation ensures that weeks never overlap a year boundary. The year is divided into periods where each period starts on the defined first day-of-week. The earliest period is referred to as week 0 if it has less than the minimal number of days and week 1 if it has at least the minimal number of days. This class is immutable and thread-safe.

    Annotations
    @SerialVersionUID()
    Exceptions thrown

    IllegalArgumentException if the minimal days value is invalid

Value Members

  1. object ChronoField extends Serializable

    A standard set of fields.

    A standard set of fields.

    This set of fields provide field-based access to manipulate a date, time or date-time. The standard set of fields can be extended by implementing TemporalField.

    These fields are intended to be applicable in multiple calendar systems. For example, most non-ISO calendar systems define dates as a year, month and day, just with slightly different rules. The documentation of each field explains how it operates.

    Specification for implementors

    This is a final, immutable and thread-safe enum.

  2. object ChronoUnit extends Serializable

    A standard set of date periods units.

    A standard set of date periods units.

    This set of units provide unit-based access to manipulate a date, time or date-time. The standard set of units can be extended by implementing TemporalUnit.

    These units are intended to be applicable in multiple calendar systems. For example, most non-ISO calendar systems define units of years, months and days, just with slightly different rules. The documentation of each unit explains how it operates.

    Specification for implementors

    This is a final, immutable and thread-safe enum.

  3. object IsoFields

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

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

    This class defines fields and units that are specific to the ISO calendar system.

    Quarter of year

    The ISO-8601 standard is based on the standard civic 12 month year. This is commonly divided into four quarters, often abbreviated as Q1, Q2, Q3 and Q4.

    January, February and March are in Q1. April, May and June are in Q2. July, August and September are in Q3. October, November and December are in Q4.

    The complete date is expressed using three fields:

    Week based years

    The ISO-8601 standard was originally intended as a data interchange format, defining a string format for dates and times. However, it also defines an alternate way of expressing the date, based on the concept of week-based-year.

    The date is expressed using three fields:

    The week-based-year itself is defined relative to the standard ISO proleptic year. It differs from the standard year in that it always starts on a Monday.

    The first week of a week-based-year is the first Monday-based week of the standard ISO year that has at least 4 days in the new year.

    • If January 1st is Monday then week 1 starts on January 1st
    • If January 1st is Tuesday then week 1 starts on December 31st of the previous standard year
    • If January 1st is Wednesday then week 1 starts on December 30th of the previous standard year
    • If January 1st is Thursday then week 1 starts on December 29th of the previous standard year
    • If January 1st is Friday then week 1 starts on January 4th
    • If January 1st is Saturday then week 1 starts on January 3rd
    • If January 1st is Sunday then week 1 starts on January 2nd

    There are 52 weeks in most week-based years, however on occasion there are 53 weeks.

    For example:

    Examples of Week based Years
    DateDay-of-weekField values
    2008-12-28SundayWeek 52 of week-based-year 2008
    2008-12-29MondayWeek 1 of week-based-year 2009
    2008-12-31WednesdayWeek 1 of week-based-year 2009
    2009-01-01ThursdayWeek 1 of week-based-year 2009
    2009-01-04SundayWeek 1 of week-based-year 2009
    2009-01-05MondayWeek 2 of week-based-year 2009

    Specification for implementors

    This class is immutable and thread-safe.

  4. object JulianFields

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

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

    The Julian Day is a standard way of expressing date and time commonly used in the scientific community. It is expressed as a decimal number of whole days where days start at midday. This class represents variations on Julian Days that count whole days from midnight.

    Specification for implementors

    This is an immutable and thread-safe class.

  5. object TemporalAdjusters

    Common implementations of TemporalAdjuster.

    Common implementations of TemporalAdjuster.

    This class provides common implementations of TemporalAdjuster. They are especially useful to document the intent of business logic and often link well to requirements. For example, these two pieces of code do the same thing, but the second one is clearer (assuming that there is a static import of this class):

    // direct manipulation
    date.withDayOfMonth(1).plusMonths(1).minusDays(1);
    // use of an adjuster from this class
    date.with(lastDayOfMonth());
    
    There are two equivalent ways of using a TemporalAdjuster. The first is to invoke the method on the interface directly. The second is to use Temporal#with(TemporalAdjuster):
    // these two lines are equivalent, but the second approach is recommended
    dateTime = adjuster.adjustInto(dateTime);
    dateTime = dateTime.with(adjuster);
    
    It is recommended to use the second approach, with(TemporalAdjuster), 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.

  6. object TemporalQueries

    Common implementations of TemporalQuery.

    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.

  7. object ValueRange extends Serializable
  8. object WeekFields extends Serializable
    Annotations
    @SerialVersionUID()

Inherited from AnyRef

Inherited from Any

Ungrouped