DurationConverters

scala.jdk.javaapi.DurationConverters

This object contains methods that convert between Scala and Java duration types.

The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.DurationConverters.

Attributes

Source
DurationConverters.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def toJava(duration: FiniteDuration): Duration

Converts a Scala FiniteDuration to a Java duration. Note that the Scala duration keeps the time unit it was created with, while a Java duration always is a pair of seconds and nanos, so the unit is lost.

Converts a Scala FiniteDuration to a Java duration. Note that the Scala duration keeps the time unit it was created with, while a Java duration always is a pair of seconds and nanos, so the unit is lost.

Value parameters

duration

the Scala FiniteDuration to convert

Attributes

Returns

a Java java.time.Duration representing the same length of time

Source
DurationConverters.scala
def toScala(duration: Duration): FiniteDuration

Converts a Java duration to a Scala duration. If the nanosecond part of the Java duration is zero, the returned duration will have a time unit of seconds. If there is a nanoseconds part, the Scala duration will have a time unit of nanoseconds.

Converts a Java duration to a Scala duration. If the nanosecond part of the Java duration is zero, the returned duration will have a time unit of seconds. If there is a nanoseconds part, the Scala duration will have a time unit of nanoseconds.

Value parameters

duration

the Java java.time.Duration to convert

Attributes

Returns

a Scala FiniteDuration with the same length, using seconds or nanoseconds as the time unit

Throws
IllegalArgumentException

If the given Java Duration is out of bounds of what can be expressed by scala.concurrent.duration.FiniteDuration.

Source
DurationConverters.scala