Package io.islandtime.clock

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

Types

Clock
Link copied to clipboard
common

An abstraction providing the current time.

For an implementation that uses the system's clock, see SystemClock. FixedClock is also available for testing purposes.

interface Clock
FixedClock
Link copied to clipboard
common

A clock with a fixed time, suitable for testing.

class FixedClock(instant: Instant,zone: TimeZone) : Clock
SystemClock
Link copied to clipboard
common

A clock that provides the time from the current system.

The time zone is treated as an immutable property of the clock, set when it is created. If you wish to follow changes to the system clock's configured time zone, you must create a new SystemClock in response to any time zone changes.

abstract class SystemClock : Clock

Functions

now
Link copied to clipboard
common

Gets the current Instant from the system clock.

fun Instant.Companion.now(): Instant

Gets the current Instant from the provided clock.

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

Gets the current Year from the system clock.

fun Year.Companion.now(): Year

Gets the current Year from the provided clock.

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

Gets the current YearMonth from the system clock.

fun YearMonth.Companion.now(): YearMonth

Gets the current YearMonth from the provided clock.

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

Gets the current Date from the system clock.

fun Date.Companion.now(): Date

Gets the current Date from the provided clock.

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

Gets the current DateTime from the system clock.

fun DateTime.Companion.now(): DateTime

Gets the current DateTime from the provided clock.

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

Gets the current OffsetDateTime from the system clock.

fun OffsetDateTime.Companion.now(): OffsetDateTime

Gets the current OffsetDateTime from the provided clock.

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

Gets the current ZonedDateTime from the system clock.

fun ZonedDateTime.Companion.now(): ZonedDateTime

Gets the current ZonedDateTime from the provided clock.

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

Gets the current Time from the system clock.

fun Time.Companion.now(): Time

Gets the current Time from the provided clock.

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

Gets the current OffsetTime from the system clock.

fun OffsetTime.Companion.now(): OffsetTime

Gets the current OffsetTime from the provided clock.

fun OffsetTime.Companion.now(clock: Clock): OffsetTime
SystemClock
Link copied to clipboard
common

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

fun SystemClock(zone: TimeZone): SystemClock