Skip to content

//core/io.islandtime/ZonedDateTime/Companion

Companion

common

object Companion

Properties

Name Summary
DefaultSortOrder

common


val DefaultSortOrder: Comparator<ZonedDateTime>

A Comparator that compares by instant, then date-time, then time zone. Using this Comparator guarantees a deterministic order when sorting.
TimelineOrder

common


val TimelineOrder: Comparator<TimePoint<*>>

A Comparator that compares by timeline order only, ignoring any offset or time zone differences.

Functions

Name Summary
fromInstant

common


fun fromInstant(dateTime: DateTime, offset: UtcOffset, zone: TimeZone): ZonedDateTime

Creates a ZonedDateTime from the instant represented by a local date-time and offset. The resulting ZonedDateTime may have a different date-time and offset depending on the time zone rules, but the instant will be the same.
fromLocal

common


fun fromLocal(dateTime: DateTime, zone: TimeZone, preferredOffset: UtcOffset? = null): ZonedDateTime

Creates a ZonedDateTime from a local date and time, optionally using a preferred offset. If the local date and time fall during an overlap, preferredOffset will be used if it represents one of the two valid offsets. If it is null or invalid, it will be ignored.
fromMillisecondOfUnixEpoch

common


fun fromMillisecondOfUnixEpoch(millisecond: Long, zone: TimeZone): ZonedDateTime

Creates a ZonedDateTime from the millisecond of the Unix epoch at zone.
fromMillisecondsSinceUnixEpoch

common


fun fromMillisecondsSinceUnixEpoch(milliseconds: Milliseconds, zone: TimeZone): ZonedDateTime

Creates a ZonedDateTime from a duration of milliseconds relative to the Unix epoch at zone.
fromSecondOfUnixEpoch

common


fun fromSecondOfUnixEpoch(second: Long, nanosecond: Int = 0, zone: TimeZone): ZonedDateTime

Creates a ZonedDateTime from the second of the Unix epoch at zone.
fromSecondsSinceUnixEpoch

common


fun fromSecondsSinceUnixEpoch(seconds: Seconds, nanosecondAdjustment: Nanoseconds = 0.nanoseconds, zone: TimeZone): ZonedDateTime

Creates a ZonedDateTime from a duration of seconds relative to the Unix epoch at zone, optionally, with some number of additional nanoseconds added to it.
now

common


fun ZonedDateTime.Companion.now(): ZonedDateTime

Gets the current ZonedDateTime from the system clock.

common


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

Gets the current ZonedDateTime from the provided clock.

jvm


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

Gets the current ZonedDateTime from the provided clock.