toDuration

Platform and version requirements: JVM (1.6), JS (1.6), Native (1.6)
fun Int.toDuration(unit: DurationUnit): Duration

Returns a Duration equal to this Int number of the specified unit.

Platform and version requirements: JVM (1.6), JS (1.6), Native (1.6)
fun Long.toDuration(unit: DurationUnit): Duration

Returns a Duration equal to this Long number of the specified unit.

Platform and version requirements: JVM (1.6), JS (1.6), Native (1.6)
fun Double.toDuration(unit: DurationUnit): Duration

Returns a Duration equal to this Double number of the specified unit.

Depending on its magnitude, the value is rounded to an integer number of nanoseconds or milliseconds.

Exceptions

IllegalArgumentException - if this Double value is NaN.

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.time/to-duration.html