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
  • 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
  • Clock
  • DateTimeException
  • DateTimeUtils
  • DayOfWeek
  • Duration
  • Instant
  • LocalDate
  • LocalDateTime
  • LocalTime
  • Month
  • MonthDay
  • OffsetDateTime
  • OffsetTime
  • Period
  • Ser
  • Year
  • YearMonth
  • ZoneId
  • ZoneOffset
  • ZoneRegion
  • ZonedDateTime

final class Duration extends TemporalAmount with Ordered[Duration] with Serializable

A time-based amount of time, such as '34.5 seconds'.

This class models a quantity or amount of time in terms of seconds and nanoseconds. It can be accessed using other duration-based units, such as minutes and hours. In addition, the DAYS unit can be used and is treated as exactly equal to 24 hours, thus ignoring daylight savings effects. See Period for the date-based equivalent to this class.

A physical duration could be of infinite length. For practicality, the duration is stored with constraints similar to Instant. The duration uses nanosecond resolution with a maximum value of the seconds that can be held in a long. This is greater than the current estimated age of the universe.

The range of a duration requires the storage of a number larger than a long. To achieve this, the class stores a long representing seconds and an int representing nanosecond-of-second, which will always be between 0 and 999,999,999.

The duration is measured in "seconds", but these are not necessarily identical to the scientific "SI second" definition based on atomic clocks. This difference only impacts durations measured near a leap-second and should not affect most applications. See Instant for a discussion as to the meaning of the second and time-scales.

Specification for implementors

This class is immutable and thread-safe.

Constructs an instance of Duration using seconds and nanoseconds.

Annotations
@SerialVersionUID()
Linear Supertypes
Serializable, Ordered[Duration], Comparable[Duration], TemporalAmount, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Duration
  2. Serializable
  3. Ordered
  4. Comparable
  5. TemporalAmount
  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: Duration): Boolean
    Definition Classes
    Ordered
  4. def <=(that: Duration): Boolean
    Definition Classes
    Ordered
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def >(that: Duration): Boolean
    Definition Classes
    Ordered
  7. def >=(that: Duration): Boolean
    Definition Classes
    Ordered
  8. def abs: Duration

    Returns a copy of this duration with a positive length.

    Returns a copy of this duration with a positive length.

    This method returns a positive duration by effectively removing the sign from any negative total length. For example, PT-1.3S will be returned as PT1.3S.

    This instance is immutable and unaffected by this method call.

    returns

    a { @code Duration} based on this duration with an absolute length, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  9. def addTo(temporal: Temporal): Temporal

    Adds this duration to the specified temporal object.

    Adds this duration to the specified temporal object.

    This returns a temporal object of the same observable type as the input with this duration added.

    In most cases, it is clearer to reverse the calling pattern by using Temporal#plus(TemporalAmount).

    // these two lines are equivalent, but the second approach is recommended
    dateTime = thisDuration.addTo(dateTime);
    dateTime = dateTime.plus(thisDuration);
    

    The calculation will add the seconds, then nanos. Only non-zero amounts will be added.

    This instance is immutable and unaffected by this method call.

    temporal

    the temporal object to adjust, not null

    returns

    an object of the same type with the adjustment made, not null

    Definition Classes
    DurationTemporalAmount
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

    DateTimeException if unable to add

  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def compare(otherDuration: Duration): Int

    Compares this duration to the specified Duration.

    Compares this duration to the specified Duration.

    The comparison is based on the total length of the durations. It is "consistent with equals", as defined by Comparable.

    otherDuration

    the other duration to compare to, not null

    returns

    the comparator value, negative if less, positive if greater

    Definition Classes
    Duration → Ordered
  13. def compareTo(other: Duration): Int
    Definition Classes
    Duration → Ordered → Comparable
  14. def dividedBy(divisor: Long): Duration

    Returns a copy of this duration divided by the specified value.

    Returns a copy of this duration divided by the specified value.

    This instance is immutable and unaffected by this method call.

    divisor

    the value to divide the duration by, positive or negative, not zero

    returns

    a { @code Duration} based on this duration divided by the specified divisor, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(other: Any): Boolean

    Checks if this duration is equal to the specified Duration.

    Checks if this duration is equal to the specified Duration.

    The comparison is based on the total length of the durations.

    other

    the other duration, null returns false

    returns

    true if the other duration is equal to this one

    Definition Classes
    Duration → AnyRef → Any
  17. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def get(unit: TemporalUnit): Long

    Gets the amount associated with the specified unit.

    Gets the amount associated with the specified unit.

    unit

    the unit to get, not null

    returns

    the amount of the unit

    Definition Classes
    DurationTemporalAmount
    Exceptions thrown

    DateTimeException if the amount cannot be obtained

  19. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  20. def getNano: Int

    Gets the number of nanoseconds within the second in this duration.

    Gets the number of nanoseconds within the second in this duration.

    The length of the duration is stored using two fields - seconds and nanoseconds. The nanoseconds part is a value from 0 to 999,999,999 that is an adjustment to the length in seconds. The total duration is defined by calling this method and #getSeconds().

    A Duration represents a directed distance between two points on the time-line. A negative duration is expressed by the negative sign of the seconds part. A duration of -1 nanosecond is stored as -1 seconds plus 999,999,999 nanoseconds.

    returns

    the nanoseconds within the second part of the length of the duration, from 0 to 999,999,999

  21. def getSeconds: Long

    Gets the number of seconds in this duration.

    Gets the number of seconds in this duration.

    The length of the duration is stored using two fields - seconds and nanoseconds. The nanoseconds part is a value from 0 to 999,999,999 that is an adjustment to the length in seconds. The total duration is defined by calling this method and #getNano().

    A Duration represents a directed distance between two points on the time-line. A negative duration is expressed by the negative sign of the seconds part. A duration of -1 nanosecond is stored as -1 seconds plus 999,999,999 nanoseconds.

    returns

    the whole seconds part of the length of the duration, positive or negative

  22. def getUnits: List[TemporalUnit]

    Gets the list of units, from largest to smallest, that fully define this amount.

    Gets the list of units, from largest to smallest, that fully define this amount.

    returns

    the list of units.

    Definition Classes
    DurationTemporalAmount
  23. def hashCode(): Int

    A hash code for this duration.

    A hash code for this duration.

    returns

    a suitable hash code

    Definition Classes
    Duration → AnyRef → Any
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. def isNegative: Boolean

    Checks if this duration is negative, excluding zero.

    Checks if this duration is negative, excluding zero.

    A Duration represents a directed distance between two points on the time-line and can therefore be positive, zero or negative. This method checks whether the length is less than zero.

    returns

    true if this duration has a total length less than zero

  26. def isZero: Boolean

    Checks if this duration is zero length.

    Checks if this duration is zero length.

    A Duration represents a directed distance between two points on the time-line and can therefore be positive, zero or negative. This method checks whether the length is zero.

    returns

    true if this duration has a total length equal to zero

  27. def minus(amountToSubtract: Long, unit: TemporalUnit): Duration

    Returns a copy of this duration with the specified duration subtracted.

    Returns a copy of this duration with the specified duration subtracted.

    The duration amount is measured in terms of the specified unit. Only a subset of units are accepted by this method. The unit must either have an exact duration or be ChronoUnit#DAYS which is treated as 24 hours. Other units throw an exception.

    This instance is immutable and unaffected by this method call.

    amountToSubtract

    the amount of the period, measured in terms of the unit, positive or negative

    unit

    the unit that the period is measured in, must have an exact duration, not null

    returns

    a { @code Duration} based on this duration with the specified duration subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  28. def minus(duration: Duration): Duration

    Returns a copy of this duration with the specified duration subtracted.

    Returns a copy of this duration with the specified duration subtracted.

    This instance is immutable and unaffected by this method call.

    duration

    the duration to subtract, positive or negative, not null

    returns

    a { @code Duration} based on this duration with the specified duration subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  29. def minusDays(daysToSubtract: Long): Duration

    Returns a copy of this duration with the specified duration in 24 hour days subtracted.

    Returns a copy of this duration with the specified duration in 24 hour days subtracted.

    This instance is immutable and unaffected by this method call.

    daysToSubtract

    the days to subtract, positive or negative

    returns

    a { @code Duration} based on this duration with the specified days subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  30. def minusHours(hoursToSubtract: Long): Duration

    Returns a copy of this duration with the specified duration in hours subtracted.

    Returns a copy of this duration with the specified duration in hours subtracted.

    This instance is immutable and unaffected by this method call.

    hoursToSubtract

    the hours to subtract, positive or negative

    returns

    a { @code Duration} based on this duration with the specified hours subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  31. def minusMillis(millisToSubtract: Long): Duration

    Returns a copy of this duration with the specified duration in milliseconds subtracted.

    Returns a copy of this duration with the specified duration in milliseconds subtracted.

    This instance is immutable and unaffected by this method call.

    millisToSubtract

    the milliseconds to subtract, positive or negative

    returns

    a { @code Duration} based on this duration with the specified milliseconds subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  32. def minusMinutes(minutesToSubtract: Long): Duration

    Returns a copy of this duration with the specified duration in minutes subtracted.

    Returns a copy of this duration with the specified duration in minutes subtracted.

    This instance is immutable and unaffected by this method call.

    minutesToSubtract

    the minutes to subtract, positive or negative

    returns

    a { @code Duration} based on this duration with the specified minutes subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  33. def minusNanos(nanosToSubtract: Long): Duration

    Returns a copy of this duration with the specified duration in nanoseconds subtracted.

    Returns a copy of this duration with the specified duration in nanoseconds subtracted.

    This instance is immutable and unaffected by this method call.

    nanosToSubtract

    the nanoseconds to subtract, positive or negative

    returns

    a { @code Duration} based on this duration with the specified nanoseconds subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  34. def minusSeconds(secondsToSubtract: Long): Duration

    Returns a copy of this duration with the specified duration in seconds subtracted.

    Returns a copy of this duration with the specified duration in seconds subtracted.

    This instance is immutable and unaffected by this method call.

    secondsToSubtract

    the seconds to subtract, positive or negative

    returns

    a { @code Duration} based on this duration with the specified seconds subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  35. def multipliedBy(multiplicand: Long): Duration

    Returns a copy of this duration multiplied by the scalar.

    Returns a copy of this duration multiplied by the scalar.

    This instance is immutable and unaffected by this method call.

    multiplicand

    the value to multiply the duration by, positive or negative

    returns

    a { @code Duration} based on this duration multiplied by the specified scalar, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  36. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  37. def negated: Duration

    Returns a copy of this duration with the length negated.

    Returns a copy of this duration with the length negated.

    This method swaps the sign of the total length of this duration. For example, PT1.3S will be returned as PT-1.3S.

    This instance is immutable and unaffected by this method call.

    returns

    a { @code Duration} based on this duration with the amount negated, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  38. final def notify(): Unit
    Definition Classes
    AnyRef
  39. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  40. def plus(amountToAdd: Long, unit: TemporalUnit): Duration

    Returns a copy of this duration with the specified duration added.

    Returns a copy of this duration with the specified duration added.

    The duration amount is measured in terms of the specified unit. Only a subset of units are accepted by this method. The unit must either have an exact duration or be ChronoUnit#DAYS which is treated as 24 hours. Other units throw an exception.

    This instance is immutable and unaffected by this method call.

    amountToAdd

    the amount of the period, measured in terms of the unit, positive or negative

    unit

    the unit that the period is measured in, must have an exact duration, not null

    returns

    a { @code Duration} based on this duration with the specified duration added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  41. def plus(duration: Duration): Duration

    Returns a copy of this duration with the specified duration added.

    Returns a copy of this duration with the specified duration added.

    This instance is immutable and unaffected by this method call.

    duration

    the duration to add, positive or negative, not null

    returns

    a { @code Duration} based on this duration with the specified duration added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  42. def plusDays(daysToAdd: Long): Duration

    Returns a copy of this duration with the specified duration in 24 hour days added.

    Returns a copy of this duration with the specified duration in 24 hour days added.

    This instance is immutable and unaffected by this method call.

    daysToAdd

    the days to add, positive or negative

    returns

    a { @code Duration} based on this duration with the specified days added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  43. def plusHours(hoursToAdd: Long): Duration

    Returns a copy of this duration with the specified duration in hours added.

    Returns a copy of this duration with the specified duration in hours added.

    This instance is immutable and unaffected by this method call.

    hoursToAdd

    the hours to add, positive or negative

    returns

    a { @code Duration} based on this duration with the specified hours added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  44. def plusMillis(millisToAdd: Long): Duration

    Returns a copy of this duration with the specified duration in milliseconds added.

    Returns a copy of this duration with the specified duration in milliseconds added.

    This instance is immutable and unaffected by this method call.

    millisToAdd

    the milliseconds to add, positive or negative

    returns

    a { @code Duration} based on this duration with the specified milliseconds added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  45. def plusMinutes(minutesToAdd: Long): Duration

    Returns a copy of this duration with the specified duration in minutes added.

    Returns a copy of this duration with the specified duration in minutes added.

    This instance is immutable and unaffected by this method call.

    minutesToAdd

    the minutes to add, positive or negative

    returns

    a { @code Duration} based on this duration with the specified minutes added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  46. def plusNanos(nanosToAdd: Long): Duration

    Returns a copy of this duration with the specified duration in nanoseconds added.

    Returns a copy of this duration with the specified duration in nanoseconds added.

    This instance is immutable and unaffected by this method call.

    nanosToAdd

    the nanoseconds to add, positive or negative

    returns

    a { @code Duration} based on this duration with the specified nanoseconds added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  47. def plusSeconds(secondsToAdd: Long): Duration

    Returns a copy of this duration with the specified duration in seconds added.

    Returns a copy of this duration with the specified duration in seconds added.

    This instance is immutable and unaffected by this method call.

    secondsToAdd

    the seconds to add, positive or negative

    returns

    a { @code Duration} based on this duration with the specified seconds added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  48. def subtractFrom(temporal: Temporal): Temporal

    Subtracts this duration from the specified temporal object.

    Subtracts this duration from the specified temporal object.

    This returns a temporal object of the same observable type as the input with this duration subtracted.

    In most cases, it is clearer to reverse the calling pattern by using Temporal#minus(TemporalAmount).

    // these two lines are equivalent, but the second approach is recommended
    dateTime = thisDuration.subtractFrom(dateTime);
    dateTime = dateTime.minus(thisDuration);
    

    The calculation will subtract the seconds, then nanos. Only non-zero amounts will be added.

    This instance is immutable and unaffected by this method call.

    temporal

    the temporal object to adjust, not null

    returns

    an object of the same type with the adjustment made, not null

    Definition Classes
    DurationTemporalAmount
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

    DateTimeException if unable to subtract

  49. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  50. def toDays: Long

    Gets the number of days in this duration.

    Gets the number of days in this duration.

    This returns the total number of days in the duration by dividing the number of seconds by 86400. This is based on the standard definition of a day as 24 hours.

    This instance is immutable and unaffected by this method call.

    returns

    the number of days in the duration, may be negative

  51. def toHours: Long

    Gets the number of hours in this duration.

    Gets the number of hours in this duration.

    This returns the total number of hours in the duration by dividing the number of seconds by 3600.

    This instance is immutable and unaffected by this method call.

    returns

    the number of hours in the duration, may be negative

  52. def toMillis: Long

    Converts this duration to the total length in milliseconds.

    Converts this duration to the total length in milliseconds.

    If this duration is too large to fit in a long milliseconds, then an exception is thrown.

    If this duration has greater than millisecond precision, then the conversion will drop any excess precision information as though the amount in nanoseconds was subject to integer division by one million.

    returns

    the total length of the duration in milliseconds

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  53. def toMinutes: Long

    Gets the number of minutes in this duration.

    Gets the number of minutes in this duration.

    This returns the total number of minutes in the duration by dividing the number of seconds by 60.

    This instance is immutable and unaffected by this method call.

    returns

    the number of minutes in the duration, may be negative

  54. def toNanos: Long

    Converts this duration to the total length in nanoseconds expressed as a long.

    Converts this duration to the total length in nanoseconds expressed as a long.

    If this duration is too large to fit in a long nanoseconds, then an exception is thrown.

    returns

    the total length of the duration in nanoseconds

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  55. def toString(): String

    A string representation of this duration using ISO-8601 seconds based representation, such as PT8H6M12.345S.

    A string representation of this duration using ISO-8601 seconds based representation, such as PT8H6M12.345S.

    The format of the returned string will be PTnHnMnS, where n is the relevant hours, minutes or seconds part of the duration. Any fractional seconds are placed after a decimal point i the seconds section. If a section has a zero value, it is omitted. The hours, minutes and seconds will all have the same sign.

    Examples:

    "20.345 seconds"                 -> "PT20.345S
    "15 minutes" (15 * 60 seconds)   -> "PT15M"
    "10 hours" (10 * 3600 seconds)   -> "PT10H"
    "2 days" (2 * 86400 seconds)     -> "PT48H"
    
    Note that multiples of 24 hours are not output as days to avoid confusion with Period.

    returns

    an ISO-8601 representation of this duration, not null

    Definition Classes
    Duration → AnyRef → Any
  56. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  59. def withNanos(nanoOfSecond: Int): Duration

    Returns a copy of this duration with the specified nano-of-second.

    Returns a copy of this duration with the specified nano-of-second.

    This returns a duration with the specified nano-of-second, retaining the seconds part of this duration.

    This instance is immutable and unaffected by this method call.

    nanoOfSecond

    the nano-of-second to represent, from 0 to 999,999,999

    returns

    a { @code Duration} based on this period with the requested nano-of-second, not null

    Exceptions thrown

    DateTimeException if the nano-of-second is invalid

  60. def withSeconds(seconds: Long): Duration

    Returns a copy of this duration with the specified amount of seconds.

    Returns a copy of this duration with the specified amount of seconds.

    This returns a duration with the specified seconds, retaining the nano-of-second part of this duration.

    This instance is immutable and unaffected by this method call.

    seconds

    the seconds to represent, may be negative

    returns

    a { @code Duration} based on this period with the requested seconds, not null

Inherited from Serializable

Inherited from Ordered[Duration]

Inherited from Comparable[Duration]

Inherited from TemporalAmount

Inherited from AnyRef

Inherited from Any

Ungrouped