kotlin-stdlib / kotlin.time / toDuration toDuration Common JVM JS Native 1.6 fun Int . toDuration ( unit : DurationUnit ) : Duration (source) Returns a Duration equal to this Int number of the specified unit . Common JVM JS Native 1.6 fun Long . toDuration ( unit : DurationUnit ) : Duration (source) Returns a Duration equal to this Long number of the specified unit . Common JVM JS Native 1.6 fun Double . toDuration ( unit : DurationUnit ) : Duration (source) 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 .