Clock

interface Clock(source)

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.

Inheritors

Types

Link copied to clipboard
object Companion

A companion object used purely for namespacing.

Link copied to clipboard
object System : Clock

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

Functions

Link copied to clipboard

Returns a TimeSource that uses this Clock to mark a time instant and to find the amount of time elapsed since that mark.

Link copied to clipboard
abstract fun now(): Instant

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

Link copied to clipboard

Returns the current date at the given time zone, according to this Clock.