Clock

A source of Instant values.

See Clock.System for the clock instance that queries the operating system.

It is not recommended to use Clock.System directly in the implementation. Instead, you can pass a Clock explicitly to the necessary functions or classes. This way, tests can be written deterministically by providing custom Clock implementations to the system under test.

Since Kotlin

2.1

Inheritors

Types

Link copied to clipboard
object Companion

A companion object used purely for namespacing.

Since Kotlin 2.1
Link copied to clipboard
object System : Clock

The Clock instance that queries the platform-specific system clock as its source of time knowledge.

Since Kotlin 2.1

Functions

Link copied to clipboard
abstract fun now(): Instant

Returns the Instant corresponding to the current time, according to this clock.

Since Kotlin 2.1