Package-level declarations

Experimental API for representing Duration values and measuring time intervals.

Experimental API for representing Duration values and measuring time intervals.

Experimental API for representing Duration values and measuring time intervals.

Experimental API for representing Duration values and measuring time intervals.

Experimental API for representing Duration values and measuring time intervals.

Types

Link copied to clipboard

An abstract class used to implement time sources that return their readings as Double values in the specified unit.

Since Kotlin 1.3
Link copied to clipboard

An abstract class used to implement time sources that return their readings as Long values in the specified unit.

Since Kotlin 1.3
Link copied to clipboard

Represents the amount of time one instant of time is away from another instant.

Since Kotlin 1.3
Link copied to clipboard

The list of possible time measurement units, in which a duration can be expressed.

Since Kotlin 1.3
actual typealias DurationUnit = TimeUnit
@ExperimentalTime
actual enum DurationUnit : Enum<DurationUnit>
@ExperimentalTime
actual enum DurationUnit : Enum<DurationUnit>
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPEALIAS])
annotation class ExperimentalTime

This annotation marks the experimental preview of the standard library API for measuring time and working with durations.

Since Kotlin 1.3
Link copied to clipboard

A time source that has programmatically updatable readings. It is useful as a predictable source of time in tests.

Since Kotlin 1.3
Link copied to clipboard
data class TimedValue<T>(val value: T, val duration: Duration)

Data class representing a result of executing an action, along with the duration of elapsed time interval.

Since Kotlin 1.3
Link copied to clipboard
abstract class TimeMark

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).

Since Kotlin 1.3
Link copied to clipboard

A source of time for measuring time intervals.

Since Kotlin 1.3

Functions

Link copied to clipboard
inline operator fun TimeMark.compareTo(other: TimeMark): Int
Link copied to clipboard
inline fun measureTime(block: () -> Unit): Duration

Executes the given function block and returns the duration of elapsed time interval.

Since Kotlin 1.3
Link copied to clipboard
inline fun <T> measureTimedValue(block: () -> T): TimedValue<T>

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.

Since Kotlin 1.3

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.

Since Kotlin 1.3
Link copied to clipboard
inline operator fun TimeMark.minus(other: TimeMark): Duration
Link copied to clipboard
inline operator fun Double.times(duration: Duration): Duration
inline operator fun Int.times(duration: Duration): Duration

Returns a duration whose value is the specified duration value multiplied by this number.

Since Kotlin 1.3
Link copied to clipboard

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

Since Kotlin 1.3

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

Since Kotlin 1.3

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

Since Kotlin 1.3
Link copied to clipboard
@ExperimentalTime
inline fun Duration.toJavaDuration(): Duration

Converts kotlin.time.Duration value to java.time.Duration value.

Since Kotlin 1.3
Link copied to clipboard
@ExperimentalTime
inline fun Duration.toKotlinDuration(): Duration

Converts java.time.Duration value to kotlin.time.Duration value.

Since Kotlin 1.3

Properties

Link copied to clipboard

Returns a Duration equal to this Int number of days.

Returns a Duration equal to this Long number of days.

Returns a Duration equal to this Double number of days.

Link copied to clipboard

Returns a Duration equal to this Int number of hours.

Returns a Duration equal to this Long number of hours.

Returns a Duration equal to this Double number of hours.

Link copied to clipboard

Returns a Duration equal to this Int number of microseconds.

Returns a Duration equal to this Long number of microseconds.

Returns a Duration equal to this Double number of microseconds.

Link copied to clipboard

Returns a Duration equal to this Int number of milliseconds.

Returns a Duration equal to this Long number of milliseconds.

Returns a Duration equal to this Double number of milliseconds.

Link copied to clipboard

Returns a Duration equal to this Int number of minutes.

Returns a Duration equal to this Long number of minutes.

Returns a Duration equal to this Double number of minutes.

Link copied to clipboard

Returns a Duration equal to this Int number of nanoseconds.

Returns a Duration equal to this Long number of nanoseconds.

Returns a Duration equal to this Double number of nanoseconds.

Link copied to clipboard

Returns a Duration equal to this Int number of seconds.

Returns a Duration equal to this Long number of seconds.

Returns a Duration equal to this Double number of seconds.