scala / 3.1 / scala / concurrent / duration / finiteduration.html

Class scala.concurrent.duration.FiniteDuration

final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration

This class represents a finite duration. Its addition and subtraction operators are overloaded to retain this guarantee statically. The range of this class is limited to +-(2^63-1)ns, which is roughly 292 years.

Supertypes

Concrete methods

Source
def *(factor: Double): Duration

Source
def *(factor: Long): FiniteDuration

Return the product of this duration and the given integer factor.

Throws
IllegalArgumentException

if the result would overflow the range of FiniteDuration

Source
def +(other: Duration): Duration

Source

Source
def -(other: Duration): Duration

Source

Source
def /(divisor: Double): Duration

Source
def /(divisor: Duration): Double

Source
def /(divisor: Long): FiniteDuration

Return the quotient of this duration and the given integer factor.

Throws
java.lang.ArithmeticException

if the factor is 0

Source
def compare(other: Duration): Int

Source
def div(divisor: Long): FiniteDuration

Return the quotient of this duration and the given integer factor.

Throws
java.lang.ArithmeticException

if the factor is 0

Source
override def equals(other: Any): Boolean

Definition Classes Any

Source

Construct a Deadline from this duration by adding it to the current instant Deadline.now.

Source
override def hashCode: Int

Definition Classes Any

Source
final def isFinite: Boolean

Source

Source

Source

Source
def mul(factor: Long): FiniteDuration

Return the product of this duration and the given integer factor.

Throws
IllegalArgumentException

if the result would overflow the range of FiniteDuration

Source

Source
final override def toCoarsest: FiniteDuration

Definition Classes Duration

Source
def toDays: Long

Source
def toHours: Long

Source
def toMicros: Long

Source
def toMillis: Long

Source

Source
def toNanos: Long

Source

Source
override def toString: String

Definition Classes Any

Source

Source

Inherited methods

Source
def <(that: Duration): Boolean

Returns true if this is less than that

Inherited from Ordered

Source
def <=(that: Duration): Boolean

Returns true if this is less than or equal to that.

Inherited from Ordered

Source
def >(that: Duration): Boolean

Returns true if this is greater than that.

Inherited from Ordered

Source
def >=(that: Duration): Boolean

Returns true if this is greater than or equal to that.

Inherited from Ordered

Source
def compareTo(that: Duration): Int

Result of comparing this with operand that.

Inherited from Ordered

Source
def div(other: Duration): Double

Return the quotient of this and that duration as floating-point number. The semantics are determined by Double as if calculating the quotient of the nanosecond lengths of both factors.

Inherited from Duration

Source
def div(divisor: Double): Duration

Return this duration divided by the scalar factor. When involving non-finite factors the semantics match those of Double.

Throws
IllegalArgumentException

in case of a finite overflow: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite durations takes place.

Inherited from Duration

Source
def gt(other: Duration): Boolean

Inherited from Duration

Source
def gteq(other: Duration): Boolean

Inherited from Duration

Source
def lt(other: Duration): Boolean

Inherited from Duration

Source
def lteq(other: Duration): Boolean

Inherited from Duration

Source
def max(other: Duration): Duration

Return the larger of this and that duration as determined by the natural ordering.

Inherited from Duration

Source
def min(other: Duration): Duration

Return the smaller of this and that duration as determined by the natural ordering.

Inherited from Duration

Source
def minus(other: Duration): Duration

Return the difference of that duration and this. When involving non-finite summands the semantics match those of Double.

Throws
IllegalArgumentException

in case of a finite overflow: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite durations takes place.

Inherited from Duration

Source
def mul(factor: Double): Duration

Return this duration multiplied by the scalar factor. When involving non-finite factors the semantics match those of Double.

Throws
IllegalArgumentException

in case of a finite overflow: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite durations takes place.

Inherited from Duration

Source
def neg(): Duration

Negate this duration. The only two values which are mapped to themselves are Duration.Zero and Duration.Undefined.

Inherited from Duration

Source
def plus(other: Duration): Duration

Return the sum of that duration and this. When involving non-finite summands the semantics match those of Double.

Throws
IllegalArgumentException

in case of a finite overflow: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite durations takes place.

Inherited from Duration

Concrete fields

Source
val length: Long

Source
val unit: TimeUnit

© 2002-2022 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://scala-lang.org/api/3.1.1/scala/concurrent/duration/FiniteDuration.html