Skip to content

//core/io.islandtime.clock

Package-level declarations

common

The default clock implementation, providing access to the current system time at up to nanosecond precision when available.

Types

Name Summary
Clock

common


interface Clock

An abstraction providing the current time.
FixedClock

common


class FixedClock(instant: Instant, val zone: TimeZone) : Clock

A clock with a fixed time, suitable for testing.
SystemClock

common


abstract class SystemClock : Clock

A clock that provides the time from the current system.

Functions

Name Summary
now

common


fun Date.Companion.now(): Date

Gets the current Date from the system clock.

common


fun DateTime.Companion.now(): DateTime

Gets the current DateTime from the system clock.

common


fun Instant.Companion.now(): Instant

Gets the current Instant from the system clock.

common


fun OffsetDateTime.Companion.now(): OffsetDateTime

Gets the current OffsetDateTime from the system clock.

common


fun OffsetTime.Companion.now(): OffsetTime

Gets the current OffsetTime from the system clock.

common


fun Time.Companion.now(): Time

Gets the current Time from the system clock.

common


fun Year.Companion.now(): Year

Gets the current Year from the system clock.

common


fun YearMonth.Companion.now(): YearMonth

Gets the current YearMonth from the system clock.

common


fun ZonedDateTime.Companion.now(): ZonedDateTime

Gets the current ZonedDateTime from the system clock.

common


fun Date.Companion.now(clock: Clock): Date

Gets the current Date from the provided clock.

common


fun DateTime.Companion.now(clock: Clock): DateTime

Gets the current DateTime from the provided clock.

common


fun Instant.Companion.now(clock: Clock): Instant

Gets the current Instant from the provided clock.

common


fun OffsetDateTime.Companion.now(clock: Clock): OffsetDateTime

Gets the current OffsetDateTime from the provided clock.

common


fun OffsetTime.Companion.now(clock: Clock): OffsetTime

Gets the current OffsetTime from the provided clock.

common


fun Time.Companion.now(clock: Clock): Time

Gets the current Time from the provided clock.

common


fun Year.Companion.now(clock: Clock): Year

Gets the current Year from the provided clock.

common


fun YearMonth.Companion.now(clock: Clock): YearMonth

Gets the current YearMonth from the provided clock.

common


fun ZonedDateTime.Companion.now(clock: Clock): ZonedDateTime

Gets the current ZonedDateTime from the provided clock.
SystemClock

common


fun SystemClock(zone: TimeZone = TimeZone.systemDefault()): SystemClock

Creates a SystemClock, optionally overriding the system's default time zone with another zone.