Package kotlin.time
Experimental API for representing Duration values and measuring time intervals.
Types
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
typealias AbstractDoubleClock = AbstractDoubleTimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
An abstract class used to implement time sources that return their readings as Double values in the specified unit.
abstract class AbstractDoubleTimeSource : TimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
typealias AbstractLongClock = AbstractLongTimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
An abstract class used to implement time sources that return their readings as Long values in the specified unit.
abstract class AbstractLongTimeSource : TimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
typealias Clock = TimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
typealias ClockMark = TimeMark
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Represents the amount of time one instant of time is away from another instant.
class Duration : Comparable<Duration>
The list of possible time measurement units, in which a duration can be expressed.
Platform and version requirements: JS (1.3), Native (1.3)
enum class DurationUnit
Platform and version requirements: JVM (1.3)
typealias DurationUnit = TimeUnit
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
typealias MonoClock = Monotonic
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
typealias TestClock = TestTimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
A time source that has programmatically updatable readings. It is useful as a predictable source of time in tests.
class TestTimeSource : AbstractLongTimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Data class representing a result of executing an action, along with the duration of elapsed time interval.
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Represents a time point notched on a particular TimeSource. Remains bound to the time source it was taken from and allows querying for the duration of time elapsed from that point (see the function elapsedNow).
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
A source of time for measuring time intervals.
Annotations
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
This annotation marks the experimental preview of the standard library API for measuring time and working with durations.
annotation class ExperimentalTime
Extensions for External Classes
Platform and version requirements: JVM (1.3), JRE8 (1.3)
Properties
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Double number of days.
val Double.days: Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Double number of hours.
val Double.hours: Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Int number of microseconds.
val Int.microseconds: Duration
Returns a Duration equal to this Long number of microseconds.
val Long.microseconds: Duration
Returns a Duration equal to this Double number of microseconds.
val Double.microseconds: Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Int number of milliseconds.
val Int.milliseconds: Duration
Returns a Duration equal to this Long number of milliseconds.
val Long.milliseconds: Duration
Returns a Duration equal to this Double number of milliseconds.
val Double.milliseconds: Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Int number of minutes.
val Int.minutes: Duration
Returns a Duration equal to this Long number of minutes.
val Long.minutes: Duration
Returns a Duration equal to this Double number of minutes.
val Double.minutes: Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Int number of nanoseconds.
val Int.nanoseconds: Duration
Returns a Duration equal to this Long number of nanoseconds.
val Long.nanoseconds: Duration
Returns a Duration equal to this Double number of nanoseconds.
val Double.nanoseconds: Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Int number of seconds.
val Int.seconds: Duration
Returns a Duration equal to this Long number of seconds.
val Long.seconds: Duration
Returns a Duration equal to this Double number of seconds.
val Double.seconds: Duration
Functions
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
operator fun TimeMark.compareTo(other: TimeMark): Int
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Executes the given function block and returns the duration of elapsed time interval.
fun measureTime(block: () -> Unit): Duration
fun TimeSource.measureTime(block: () -> Unit): Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Executes the given function block and returns an instance of TimedValue class, containing both the result of the function execution and the duration of elapsed time interval.
fun <T> measureTimedValue(block: () -> T): TimedValue<T>
Executes the given block and returns an instance of TimedValue class, containing both the result of function execution and the duration of elapsed time interval.
fun <T> TimeSource.measureTimedValue(
block: () -> T
): TimedValue<T>
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
operator fun TimeMark.minus(other: TimeMark): Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a duration whose value is the specified duration value multiplied by this number.
operator fun Int.times(duration: Duration): Duration
operator fun Double.times(duration: Duration): Duration
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Duration equal to this Int number of the specified unit.
fun Int.toDuration(unit: DurationUnit): Duration
Returns a Duration equal to this Long number of the specified unit.
fun Long.toDuration(unit: DurationUnit): Duration
Returns a Duration equal to this Double number of the specified unit.
fun Double.toDuration(unit: DurationUnit): Duration
Platform and version requirements: JVM (1.3), JRE8 (1.3)
Converts kotlin.time.Duration value to java.time.Duration value.
fun Duration.toJavaDuration(): Duration