Instant

@Serializable(with = InstantIso8601Serializer::class)
actual class Instant : Comparable<Instant> (source)
@Serializable(with = InstantIso8601Serializer::class)
expect class Instant : Comparable<Instant> (source)

A moment in time.

A point in time must be uniquely identified, so that it is independent of a time zone. For example, 1970-01-01, 00:00:00 does not represent a moment in time, since this would happen at different times in different time zones: someone in Tokyo would think its already 1970-01-01 several hours earlier than someone in Berlin would. To represent such entities, use LocalDateTime. In contrast, "the moment the clocks in London first showed 00:00 on Jan 1, 2000" is a specific moment in time, as is "1970-01-01, 00:00:00 UTC+0", and so it can be represented as an Instant.

Instant uses the UTC-SLS (smeared leap second) time scale. This time scale doesn't contain instants corresponding to leap seconds, but instead "smears" positive and negative leap seconds among the last 1000 seconds of the day when a leap second happens.

Some ways in which Instant can be acquired are:

@Serializable(with = InstantIso8601Serializer::class)
actual class Instant : Comparable<Instant> (source)
@Serializable(with = InstantIso8601Serializer::class)
actual class Instant : Comparable<Instant> (source)

Types

Link copied to clipboard
actual object Companion
expect object Companion
actual object Companion
actual object Companion

Properties

Link copied to clipboard
actual val epochSeconds: Long
expect val epochSeconds: Long

The number of seconds from the epoch instant 1970-01-01T00:00:00Z rounded down to a Long number.

actual val epochSeconds: Long
actual val epochSeconds: Long
Link copied to clipboard

Returns true if the instant is Instant.DISTANT_FUTURE or later.

Link copied to clipboard

Returns true if the instant is Instant.DISTANT_PAST or earlier.

Link copied to clipboard

The number of nanoseconds by which this instant is later than epochSeconds from the epoch instant.

Functions

Link copied to clipboard
actual open operator override fun compareTo(other: Instant): Int
expect open operator override fun compareTo(other: Instant): Int

Compares this instant with the other instant. Returns zero if this instant represents the same moment as the other (i.e. equal to other), a negative number if this instant is earlier than the other, and a positive number if this instant is later than the other.

actual open operator override fun compareTo(other: Instant): Int
actual open operator override fun compareTo(other: Instant): Int
Link copied to clipboard
fun Instant.daysUntil(other: Instant, timeZone: TimeZone): Int

Returns the number of whole days between two instants in the specified timeZone.

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun Instant.format(format: DateTimeFormat<DateTimeComponents>, offset: UtcOffset = UtcOffset.ZERO): String

Formats this value using the given format using the given offset.

hashCode
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
open override fun hashCode(): Int
Link copied to clipboard
actual operator fun minus(duration: Duration): Instant
actual operator fun minus(other: Instant): Duration
expect operator fun minus(duration: Duration): Instant

Returns an instant that is the result of subtracting the specified duration from this instant.

expect operator fun minus(other: Instant): Duration

Returns the Duration between two instants: other and this.

actual operator fun minus(duration: Duration): Instant
actual operator fun minus(other: Instant): Duration
actual operator fun minus(duration: Duration): Instant
actual operator fun minus(other: Instant): Duration
Link copied to clipboard
actual fun Instant.minus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant

Returns an instant that is the result of subtracting the value number of the specified unit from this instant.

fun Instant.minus(period: DateTimePeriod, timeZone: TimeZone): Instant

Returns an instant that is the result of subtracting components of DateTimePeriod from this instant. The components are subtracted in the order from the largest units to the smallest, i.e. from years to nanoseconds.

Returns the whole number of the specified time units between other and this instants.

fun Instant.minus(other: Instant, timeZone: TimeZone): DateTimePeriod

Returns a DateTimePeriod representing the difference between other and this instants.

expect fun Instant.minus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant
fun Instant.minus(value: Long, unit: DateTimeUnit, timeZone: TimeZone): Instant

Returns an instant that is the result of subtracting the value number of the specified unit from this instant in the specified timeZone.

fun Instant.minus(other: Instant, unit: DateTimeUnit, timeZone: TimeZone): Long

Returns the whole number of the specified date or time units between other and this instants in the specified timeZone.

actual fun Instant.minus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant
actual fun Instant.minus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant
Link copied to clipboard
fun Instant.monthsUntil(other: Instant, timeZone: TimeZone): Int

Returns the number of whole months between two instants in the specified timeZone.

Link copied to clipboard

Finds the offset from UTC the specified timeZone has at this instant of physical time.

Link copied to clipboard
actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod
expect fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod

Returns a DateTimePeriod representing the difference between this and other instants.

actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod
actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod
Link copied to clipboard
actual operator fun plus(duration: Duration): Instant
expect operator fun plus(duration: Duration): Instant

Returns an instant that is the result of adding the specified duration to this instant.

actual operator fun plus(duration: Duration): Instant
actual operator fun plus(duration: Duration): Instant
Link copied to clipboard
actual fun Instant.plus(value: Long, unit: DateTimeUnit.TimeBased): Instant
actual fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Instant
actual fun Instant.plus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant
actual fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZone): Instant
expect fun Instant.plus(value: Long, unit: DateTimeUnit.TimeBased): Instant

Returns an instant that is the result of adding the value number of the specified unit to this instant.

expect fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Instant

Returns an instant that is the result of adding components of DateTimePeriod to this instant. The components are added in the order from the largest units to the smallest, i.e. from years to nanoseconds.

expect fun Instant.plus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant
expect fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZone): Instant

Returns an instant that is the result of adding the value number of the specified unit to this instant in the specified timeZone.

actual fun Instant.plus(value: Long, unit: DateTimeUnit.TimeBased): Instant
actual fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Instant
actual fun Instant.plus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant
actual fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZone): Instant
actual fun Instant.plus(value: Long, unit: DateTimeUnit.TimeBased): Instant
actual fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Instant
actual fun Instant.plus(value: Int, unit: DateTimeUnit, timeZone: TimeZone): Instant
actual fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZone): Instant
Link copied to clipboard

Returns the number of milliseconds from the epoch instant 1970-01-01T00:00:00Z.

Link copied to clipboard
Link copied to clipboard

Converts the Instant to an instance of JS Date.

Link copied to clipboard

Returns a civil date/time value that this instant has in the specified timeZone.

Link copied to clipboard
fun Instant.toNSDate(): <Error class: unknown class>

Converts the Instant to an instance of NSDate.

Link copied to clipboard
actual open override fun toString(): String
expect open override fun toString(): String

Converts this instant to the ISO-8601 string representation.

actual open override fun toString(): String
actual open override fun toString(): String
Link copied to clipboard
actual fun Instant.until(other: Instant, unit: DateTimeUnit, timeZone: TimeZone): Long

Returns the whole number of the specified time units between this and other instants.

expect fun Instant.until(other: Instant, unit: DateTimeUnit, timeZone: TimeZone): Long

Returns the whole number of the specified date or time units between this and other instants in the specified timeZone.

actual fun Instant.until(other: Instant, unit: DateTimeUnit, timeZone: TimeZone): Long
actual fun Instant.until(other: Instant, unit: DateTimeUnit, timeZone: TimeZone): Long
Link copied to clipboard
fun Instant.yearsUntil(other: Instant, timeZone: TimeZone): Int

Returns the number of whole years between two instants in the specified timeZone.