Skip to content

//core/io.islandtime/Instant

Instant

common

@Serializable(with = InstantIsoSerializer::class)

class Instant : TimePoint<Instant> , Comparable<Instant>

An instant in time with nanosecond-precision.

Types

Name Summary
Companion

common


object Companion

Properties

Name Summary
additionalNanosecondsSinceUnixEpoch

common


open val additionalNanosecondsSinceUnixEpoch: Nanoseconds

The number of additional nanoseconds on top of secondsSinceUnixEpoch.
millisecondOfUnixEpoch

common


open override val millisecondOfUnixEpoch: Long

The millisecond of the Unix epoch.
millisecondsSinceUnixEpoch

common


open override val millisecondsSinceUnixEpoch: Milliseconds

The number of milliseconds since the Unix epoch of 1970-01-01T00:00Z.
nanosecond

common


open override val nanosecond: Int

The nanosecond of the second.
secondOfUnixEpoch

common


open override val secondOfUnixEpoch: Long

The second of the Unix epoch.
secondsSinceUnixEpoch

common


open val secondsSinceUnixEpoch: Seconds

The number of seconds since the Unix epoch of 1970-01-01T00:00Z.

Functions

Name Summary
at

common


infix fun Instant.at(zone: TimeZone): ZonedDateTime

Combines an instant with a time zone to create a ZonedDateTime.

common


infix fun Instant.at(offset: UtcOffset): OffsetDateTime

Combines an instant with a UTC offset to create an OffsetDateTime.
compareTo

common


open operator override fun compareTo(other: Instant): Int

common


open operator fun compareTo(other: TimePoint<*>): Int

Compares this time point with another time point.
equals

common


open operator override fun equals(other: Any?): Boolean
hashCode

common


open override fun hashCode(): Int
isSameInstantAs

common


open fun isSameInstantAs(other: TimePoint<*>): Boolean

Checks if this time point represents the same instant as other. Unlike the equals operator, equality is determined solely by timeline order.
minus

common


operator fun minus(days: Days): Instant

Returns this instant with a number of 24-hour days subtracted from it.

common


operator fun minus(other: Duration): Instant

common


open operator override fun minus(hours: Hours): Instant

Returns this instant with hours subtracted from it.

common


open operator override fun minus(microseconds: Microseconds): Instant

Returns this instant with microseconds subtracted from it.

common


open operator override fun minus(milliseconds: Milliseconds): Instant

Returns this instant with milliseconds subtracted from it.

common


open operator override fun minus(minutes: Minutes): Instant

Returns this instant with minutes subtracted from it.

common


open operator override fun minus(nanoseconds: Nanoseconds): Instant

Returns this instant with nanoseconds subtracted from it.

common


open operator override fun minus(seconds: Seconds): Instant

Returns this instant with seconds subtracted from it.

common


operator fun minus(duration: Duration): Instant

Returns this instant with duration subtracted from it.
plus

common


operator fun plus(days: Days): Instant

Returns this instant with a number of 24-hour days added to it.

common


operator fun plus(other: Duration): Instant

common


open operator override fun plus(hours: Hours): Instant

Returns this instant with hours added to it.

common


open operator override fun plus(microseconds: Microseconds): Instant

Returns this instant with microseconds added to it.

common


open operator override fun plus(milliseconds: Milliseconds): Instant

Returns this instant with milliseconds added to it.

common


open operator override fun plus(minutes: Minutes): Instant

Returns this instant with minutes added to it.

common


open operator override fun plus(nanoseconds: Nanoseconds): Instant

Returns this instant with nanoseconds added to it.

common


open operator override fun plus(seconds: Seconds): Instant

Returns this instant with seconds added to it.

common


operator fun plus(duration: Duration): Instant

Returns this instant with duration added to it.
rangeTo

common


operator fun rangeTo(other: Instant): InstantInterval
roundedDownTo

common


fun Instant.roundedDownTo(unit: TimeUnit): Instant

Returns this instant, rounded down to match the precision of a given unit.
roundedDownToNearest

common


fun Instant.roundedDownToNearest(increment: Hours): Instant

Returns this instant, rounded down to the nearest hour that satisfies the increment.

common


fun Instant.roundedDownToNearest(increment: Microseconds): Instant

Returns this instant, rounded down to the nearest microsecond that satisfies the increment.

common


fun Instant.roundedDownToNearest(increment: Milliseconds): Instant

Returns this instant, rounded down to the nearest millisecond that satisfies the increment.

common


fun Instant.roundedDownToNearest(increment: Minutes): Instant

Returns this instant, rounded down to the nearest minute that satisfies the increment.

common


fun Instant.roundedDownToNearest(increment: Nanoseconds): Instant

Returns this instant, rounded down to the nearest nanosecond that satisfies the increment.

common


fun Instant.roundedDownToNearest(increment: Seconds): Instant

Returns this instant, rounded down to the nearest second that satisfies the increment.
roundedTo

common


fun Instant.roundedTo(unit: TimeUnit): Instant

Returns this instant, rounded to match the precision of a given unit. If the time is halfway between whole values of the unit, it will be rounded up.
roundedToNearest

common


fun Instant.roundedToNearest(increment: Hours): Instant

Returns this instant, rounded to the nearest hour that satisfies the increment. If the time is halfway between increments, it will be rounded up.

common


fun Instant.roundedToNearest(increment: Microseconds): Instant

Returns this instant, rounded to the nearest microsecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

common


fun Instant.roundedToNearest(increment: Milliseconds): Instant

Returns this instant, rounded to the nearest millisecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

common


fun Instant.roundedToNearest(increment: Minutes): Instant

Returns this instant, rounded to the nearest minute that satisfies the increment. If the time is halfway between increments, it will be rounded up.

common


fun Instant.roundedToNearest(increment: Nanoseconds): Instant

Returns this instant, rounded to the nearest nanosecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

common


fun Instant.roundedToNearest(increment: Seconds): Instant

Returns this instant, rounded to the nearest second that satisfies the increment. If the time is halfway between increments, it will be rounded up.
roundedUpTo

common


fun Instant.roundedUpTo(unit: TimeUnit): Instant

Returns this instant, rounded up to match the precision of a given unit.
roundedUpToNearest

common


fun Instant.roundedUpToNearest(increment: Hours): Instant

Returns this instant, rounded up to the nearest hour that satisfies the increment.

common


fun Instant.roundedUpToNearest(increment: Microseconds): Instant

Returns this instant, rounded up to the nearest microsecond that satisfies the increment.

common


fun Instant.roundedUpToNearest(increment: Milliseconds): Instant

Returns this instant, rounded up to the nearest millisecond that satisfies the increment.

common


fun Instant.roundedUpToNearest(increment: Minutes): Instant

Returns this instant, rounded up to the nearest minute that satisfies the increment.

common


fun Instant.roundedUpToNearest(increment: Nanoseconds): Instant

Returns this instant, rounded up to the nearest nanosecond that satisfies the increment.

common


fun Instant.roundedUpToNearest(increment: Seconds): Instant

Returns this instant, rounded up to the nearest second that satisfies the increment.
toDateAt

common


fun Instant.toDateAt(zone: TimeZone): Date

Converts this instant to the corresponding Date in zone.

common


fun Instant.toDateAt(offset: UtcOffset): Date

Converts this instant to the corresponding Date at offset.
toDateTimeAt

common


fun Instant.toDateTimeAt(zone: TimeZone): DateTime

Converts this instant to the corresponding DateTime in zone.

common


fun Instant.toDateTimeAt(offset: UtcOffset): DateTime

Converts this instant to the corresponding DateTime at offset.
toJavaInstant

jvm


fun Instant.toJavaInstant(): Instant

Converts this instant to an equivalent Java Instant.
toNSDate

darwin


fun <T> TimePoint<T>.toNSDate(): <Error class: unknown class>

Converts this time point to an NSDate.
toString

common


open override fun toString(): String

Converts this instant to a string in ISO-8601 extended format. For example, 2020-02-13T02:30:05.367Z.
truncatedTo

common


fun Instant.truncatedTo(unit: TimeUnit): Instant

Returns this instant, rounded down to match the precision of a given unit.
until

common


infix fun Instant.until(to: Instant): InstantInterval

Creates an InstantInterval from this instant up to, but not including to.