Instant

An instant in time with nanosecond-precision.

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

Types

Companion
Link copied to clipboard
common
object Companion

Functions

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

Compares this time point with another time point.

Time points can be compared to other time points based on timeline order, but aren't required to implement the Comparable interface since they don't necessarily have a natural order that's consistent with equals.

open operator override fun compareTo(other: TimePoint<*>): Int
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
isSameInstantAs
Link copied to clipboard
common

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

open override fun isSameInstantAs(other: TimePoint<*>): Boolean
minus
Link copied to clipboard
common
operator fun minus(other: Duration): Instant
operator fun minus(days: IntDays): Instant
operator fun minus(days: LongDays): Instant
open operator override fun minus(hours: IntHours): Instant
open operator override fun minus(hours: LongHours): Instant
open operator override fun minus(minutes: IntMinutes): Instant
open operator override fun minus(minutes: LongMinutes): Instant
open operator override fun minus(seconds: IntSeconds): Instant
open operator override fun minus(seconds: LongSeconds): Instant
open operator override fun minus(milliseconds: IntMilliseconds): Instant
open operator override fun minus(milliseconds: LongMilliseconds): Instant
open operator override fun minus(microseconds: IntMicroseconds): Instant
open operator override fun minus(microseconds: LongMicroseconds): Instant
open operator override fun minus(nanoseconds: IntNanoseconds): Instant
open operator override fun minus(nanoseconds: LongNanoseconds): Instant
plus
Link copied to clipboard
common
operator fun plus(other: Duration): Instant
operator fun plus(days: IntDays): Instant
operator fun plus(days: LongDays): Instant
open operator override fun plus(hours: IntHours): Instant
open operator override fun plus(hours: LongHours): Instant
open operator override fun plus(minutes: IntMinutes): Instant
open operator override fun plus(minutes: LongMinutes): Instant
open operator override fun plus(seconds: IntSeconds): Instant
open operator override fun plus(seconds: LongSeconds): Instant
open operator override fun plus(milliseconds: IntMilliseconds): Instant
open operator override fun plus(milliseconds: LongMilliseconds): Instant
open operator override fun plus(microseconds: IntMicroseconds): Instant
open operator override fun plus(microseconds: LongMicroseconds): Instant
open operator override fun plus(nanoseconds: IntNanoseconds): Instant
open operator override fun plus(nanoseconds: LongNanoseconds): Instant
rangeTo
Link copied to clipboard
common
operator fun rangeTo(other: Instant): InstantInterval
toString
Link copied to clipboard
common

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

open override fun toString(): String

Properties

additionalNanosecondsSinceUnixEpoch
Link copied to clipboard
common

The number of additional nanoseconds on top of secondsSinceUnixEpoch.

open override val additionalNanosecondsSinceUnixEpoch: IntNanoseconds
millisecondOfUnixEpoch
Link copied to clipboard
common

The millisecond of the Unix epoch.

open override val millisecondOfUnixEpoch: Long
millisecondsSinceUnixEpoch
Link copied to clipboard
common

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

open override val millisecondsSinceUnixEpoch: LongMilliseconds
nanosecond
Link copied to clipboard
common

The nanosecond of the second.

open override val nanosecond: Int
secondOfUnixEpoch
Link copied to clipboard
common

The second of the Unix epoch.

open override val secondOfUnixEpoch: Long
secondsSinceUnixEpoch
Link copied to clipboard
common

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

open override val secondsSinceUnixEpoch: LongSeconds

Extensions

at
Link copied to clipboard
common

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

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

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

infix fun Instant.at(zone: TimeZone): ZonedDateTime
roundedDownTo
Link copied to clipboard
common

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

This is equivalent to truncatedTo.

fun Instant.roundedDownTo(unit: TimeUnit): Instant
roundedDownToNearest
Link copied to clipboard
common

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

The increment must multiply evenly into a 24-hour day.

fun Instant.roundedDownToNearest(increment: IntHours): Instant

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

The increment must multiply evenly into an hour.

fun Instant.roundedDownToNearest(increment: IntMinutes): Instant

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

The increment must multiply evenly into a minute.

fun Instant.roundedDownToNearest(increment: IntSeconds): Instant

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

The increment must multiply evenly into a second.

fun Instant.roundedDownToNearest(increment: IntMilliseconds): Instant

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

The increment must multiply evenly into a second.

fun Instant.roundedDownToNearest(increment: IntMicroseconds): Instant

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

The increment must multiply evenly into a second.

fun Instant.roundedDownToNearest(increment: IntNanoseconds): Instant
roundedTo
Link copied to clipboard
common

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.

fun Instant.roundedTo(unit: TimeUnit): Instant
roundedToNearest
Link copied to clipboard
common

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

The increment must multiply evenly into a 24-hour day.

fun Instant.roundedToNearest(increment: IntHours): 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.

The increment must multiply evenly into an hour.

fun Instant.roundedToNearest(increment: IntMinutes): 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.

The increment must multiply evenly into a minute.

fun Instant.roundedToNearest(increment: IntSeconds): 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.

The increment must multiply evenly into a second.

fun Instant.roundedToNearest(increment: IntMilliseconds): 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.

The increment must multiply evenly into a second.

fun Instant.roundedToNearest(increment: IntMicroseconds): 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.

The increment must multiply evenly into a second.

fun Instant.roundedToNearest(increment: IntNanoseconds): Instant
roundedUpTo
Link copied to clipboard
common

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

fun Instant.roundedUpTo(unit: TimeUnit): Instant
roundedUpToNearest
Link copied to clipboard
common

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

The increment must multiply evenly into a 24-hour day.

fun Instant.roundedUpToNearest(increment: IntHours): Instant

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

The increment must multiply evenly into an hour.

fun Instant.roundedUpToNearest(increment: IntMinutes): Instant

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

The increment must multiply evenly into a minute.

fun Instant.roundedUpToNearest(increment: IntSeconds): Instant

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

The increment must multiply evenly into a second.

fun Instant.roundedUpToNearest(increment: IntMilliseconds): Instant

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

The increment must multiply evenly into a second.

fun Instant.roundedUpToNearest(increment: IntMicroseconds): Instant

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

The increment must multiply evenly into a second.

fun Instant.roundedUpToNearest(increment: IntNanoseconds): Instant
toDateAt
Link copied to clipboard
common

Converts this instant to the corresponding Date at offset.

fun Instant.toDateAt(offset: UtcOffset): Date

Converts this instant to the corresponding Date in zone.

fun Instant.toDateAt(zone: TimeZone): Date
toDateTimeAt
Link copied to clipboard
common

Converts this instant to the corresponding DateTime at offset.

fun Instant.toDateTimeAt(offset: UtcOffset): DateTime

Converts this instant to the corresponding DateTime in zone.

fun Instant.toDateTimeAt(zone: TimeZone): DateTime
toJavaInstant
Link copied to clipboard

Converts this instant to an equivalent Java Instant.

fun Instant.toJavaInstant(): Instant
truncatedTo
Link copied to clipboard
common

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

This is equivalent to roundedDownTo.

fun Instant.truncatedTo(unit: TimeUnit): Instant
until
Link copied to clipboard
common

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

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