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
interface Clock

An abstraction providing the current time.

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

A clock with a fixed time, suitable for testing.

SystemClock
Link copied to clipboard
common
abstract class SystemClock : Clock

A clock that provides the time from the current system.

Functions

now
Link copied to clipboard
common
fun Date.Companion.now(): Date

Gets the current Date from the system clock.

fun DateTime.Companion.now(): DateTime

Gets the current DateTime from the system clock.

fun Instant.Companion.now(): Instant

Gets the current Instant from the system clock.

fun OffsetDateTime.Companion.now(): OffsetDateTime

Gets the current OffsetDateTime from the system clock.

fun OffsetTime.Companion.now(): OffsetTime

Gets the current OffsetTime from the system clock.

fun Time.Companion.now(): Time

Gets the current Time from the system clock.

fun Year.Companion.now(): Year

Gets the current Year from the system clock.

fun YearMonth.Companion.now(): YearMonth

Gets the current YearMonth from the system clock.

fun ZonedDateTime.Companion.now(): ZonedDateTime

Gets the current ZonedDateTime from the system clock.

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

Gets the current Date from the provided clock.

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

Gets the current DateTime from the provided clock.

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

Gets the current Instant from the provided clock.

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

Gets the current OffsetDateTime from the provided clock.

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

Gets the current OffsetTime from the provided clock.

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

Gets the current Time from the provided clock.

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

Gets the current Year from the provided clock.

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

Gets the current YearMonth from the provided clock.

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

Gets the current ZonedDateTime from the provided clock.

SystemClock
Link copied to clipboard
common
fun SystemClock(zone: TimeZone = TimeZone.systemDefault()): SystemClock

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