Object/Class

org.threeten.bp

Duration

Related Docs: class Duration | package bp

Permalink

object Duration extends Serializable

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Duration
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. lazy val ZERO: Duration

    Permalink

    Constant for a duration of zero.

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def between(startInclusive: Temporal, endExclusive: Temporal): Duration

    Permalink

    Obtains an instance of Duration representing the duration between two instants.

    Obtains an instance of Duration representing the duration between two instants.

    Obtains a Duration representing the duration between two instants. This calculates the duration between two temporal objects of the same type. The difference in seconds is calculated using TemporalUnit). The difference in nanoseconds is calculated using by querying the NANO_OF_SECOND field.

    The result of this method can be a negative period if the end is before the start. To guarantee to obtain a positive duration call abs() on the result.

    startInclusive

    the start instant, inclusive, not null

    endExclusive

    the end instant, exclusive, not null

    returns

    a { @code Duration}, not null

    Exceptions thrown

    ArithmeticException if the calculation exceeds the capacity of { @code Duration}

    DateTimeException if the seconds between the temporals cannot be obtained

  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def from(amount: TemporalAmount): Duration

    Permalink

    Obtains an instance of Duration from an amount.

    Obtains an instance of Duration from an amount.

    This obtains a duration based on the specified amount. A TemporalAmount represents an amount of time, which may be date-based or time-based, which this factory extracts to a duration.

    The conversion loops around the set of units from the amount and uses the duration of the unit to calculate the total Duration. 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. If any other units are found then an exception is thrown.

    amount

    the amount to convert, not null

    returns

    a { @code Duration}, not null

    Exceptions thrown

    ArithmeticException if a numeric overflow occurs

    DateTimeException if the amount cannot be converted

  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. def of(amount: Long, unit: TemporalUnit): Duration

    Permalink

    Obtains an instance of Duration from a duration in the specified unit.

    Obtains an instance of Duration from a duration in the specified unit.

    The parameters represent the two parts of a phrase like '6 Hours'. For example:

    Duration.of(3, SECONDS);
    Duration.of(465, HOURS);
    
    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.

    amount

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

    unit

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

    returns

    a { @code Duration}, not null

    Exceptions thrown

    ArithmeticException if a numeric overflow occurs

    DateTimeException if the period unit has an estimated duration

  19. def ofDays(days: Long): Duration

    Permalink

    Obtains an instance of Duration from a number of standard 24 hour days.

    Obtains an instance of Duration from a number of standard 24 hour days.

    The seconds are calculated based on the standard definition of a day, where each day is 86400 seconds which implies a 24 hour day. The nanosecond in second field is set to zero.

    days

    the number of days, positive or negative

    returns

    a { @code Duration}, not null

    Exceptions thrown

    ArithmeticException if the input days exceeds the capacity of { @code Duration}

  20. def ofHours(hours: Long): Duration

    Permalink

    Obtains an instance of Duration from a number of standard length hours.

    Obtains an instance of Duration from a number of standard length hours.

    The seconds are calculated based on the standard definition of an hour, where each hour is 3600 seconds. The nanosecond in second field is set to zero.

    hours

    the number of hours, positive or negative

    returns

    a { @code Duration}, not null

    Exceptions thrown

    ArithmeticException if the input hours exceeds the capacity of { @code Duration}

  21. def ofMillis(millis: Long): Duration

    Permalink

    Obtains an instance of Duration from a number of milliseconds.

    Obtains an instance of Duration from a number of milliseconds.

    The seconds and nanoseconds are extracted from the specified milliseconds.

    millis

    the number of milliseconds, positive or negative

    returns

    a { @code Duration}, not null

  22. def ofMinutes(minutes: Long): Duration

    Permalink

    Obtains an instance of Duration from a number of standard length minutes.

    Obtains an instance of Duration from a number of standard length minutes.

    The seconds are calculated based on the standard definition of a minute, where each minute is 60 seconds. The nanosecond in second field is set to zero.

    minutes

    the number of minutes, positive or negative

    returns

    a { @code Duration}, not null

    Exceptions thrown

    ArithmeticException if the input minutes exceeds the capacity of { @code Duration}

  23. def ofNanos(nanos: Long): Duration

    Permalink

    Obtains an instance of Duration from a number of nanoseconds.

    Obtains an instance of Duration from a number of nanoseconds.

    The seconds and nanoseconds are extracted from the specified nanoseconds.

    nanos

    the number of nanoseconds, positive or negative

    returns

    a { @code Duration}, not null

  24. def ofSeconds(seconds: Long, nanoAdjustment: Long): Duration

    Permalink

    Obtains an instance of Duration from a number of seconds and an adjustment in nanoseconds.

    Obtains an instance of Duration from a number of seconds and an adjustment in nanoseconds.

    This method allows an arbitrary number of nanoseconds to be passed in. The factory will alter the values of the second and nanosecond in order to ensure that the stored nanosecond is in the range 0 to 999,999,999. For example, the following will result in the exactly the same duration:

    Duration.ofSeconds(3, 1);
    Duration.ofSeconds(4, -999_999_999);
    Duration.ofSeconds(2, 1000_000_001);
    

    seconds

    the number of seconds, positive or negative

    nanoAdjustment

    the nanosecond adjustment to the number of seconds, positive or negative

    returns

    a { @code Duration}, not null

    Exceptions thrown

    ArithmeticException if the adjustment causes the seconds to exceed the capacity of { @code Duration}

  25. def ofSeconds(seconds: Long): Duration

    Permalink

    Obtains an instance of Duration from a number of seconds.

    Obtains an instance of Duration from a number of seconds.

    The nanosecond in second field is set to zero.

    seconds

    the number of seconds, positive or negative

    returns

    a { @code Duration}, not null

  26. def parse(text: CharSequence): Duration

    Permalink

    Obtains a Duration from a text string such as PnDTnHnMn.nS.

    Obtains a Duration from a text string such as PnDTnHnMn.nS.

    This will parse a textual representation of a duration, including the string produced by toString(). The formats accepted are based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours.

    The string starts with an optional sign, denoted by the ASCII negative or positive symbol. If negative, the whole period is negated. The ASCII letter "P" is next in upper or lower case. There are then four sections, each consisting of a number and a suffix. The sections have suffixes in ASCII of "D", "H", "M" and "S" for days, hours, minutes and seconds, accepted in upper or lower case. The suffixes must occur in order. The ASCII letter "T" must occur before the first occurrence, if any, of an hour, minute or second section. At least one of the four sections must be present, and if "T" is present there must be at least one section after the "T". The number part of each section must consist of one or more ASCII digits. The number may be prefixed by the ASCII negative or positive symbol. The number of days, hours and minutes must parse to a long. The number of seconds must parse to a long with optional fraction. The decimal point may be either a dot or a comma. The fractional part may have from zero to 9 digits.

    The leading plus/minus sign, and negative values for other units are not part of the ISO-8601 standard.

    Examples:

    "PT20.345S" -> parses as "20.345 seconds"
    "PT15M"     -> parses as "15 minutes" (where a minute is 60 seconds)
    "PT10H"     -> parses as "10 hours" (where an hour is 3600 seconds)
    "P2D"       -> parses as "2 days" (where a day is 24 hours or 86400 seconds)
    "P2DT3H4M"  -> parses as "2 days, 3 hours and 4 minutes"
    "P-6H3M"    -> parses as "-6 hours and +3 minutes"
    "-P6H3M"    -> parses as "-6 hours and -3 minutes"
    "-P-6H+3M"  -> parses as "+6 hours and -3 minutes"
    

    text

    the text to parse, not null

    returns

    the parsed duration, not null

    Exceptions thrown

    DateTimeParseException if the text cannot be parsed to a duration

  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  28. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  29. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped