Instant

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

An instant in time with nanosecond-precision.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

compareTo
Link copied to clipboard
common
open operator fun compareTo(other: TimePoint<*>): Int

Compares this time point with another time point.

open operator override fun compareTo(other: Instant): 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
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
Link copied to clipboard
common
operator fun minus(days: Days): Instant

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

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

Returns this instant with hours subtracted from it.

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

Returns this instant with microseconds subtracted from it.

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

Returns this instant with milliseconds subtracted from it.

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

Returns this instant with minutes subtracted from it.

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

Returns this instant with nanoseconds subtracted from it.

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

Returns this instant with seconds subtracted from it.

operator fun minus(duration: Duration): Instant

Returns this instant with duration subtracted from it.

plus
Link copied to clipboard
common
operator fun plus(days: Days): Instant

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

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

Returns this instant with hours added to it.

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

Returns this instant with microseconds added to it.

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

Returns this instant with milliseconds added to it.

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

Returns this instant with minutes added to it.

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

Returns this instant with nanoseconds added to it.

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

Returns this instant with seconds added to it.

operator fun plus(duration: Duration): Instant

Returns this instant with duration added to it.

rangeTo
Link copied to clipboard
common
operator fun rangeTo(other: Instant): InstantInterval
toString
Link copied to clipboard
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.

Properties

additionalNanosecondsSinceUnixEpoch
Link copied to clipboard
common
open val additionalNanosecondsSinceUnixEpoch: Nanoseconds

The number of additional nanoseconds on top of secondsSinceUnixEpoch.

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

The millisecond of the Unix epoch.

millisecondsSinceUnixEpoch
Link copied to clipboard
common
open override val millisecondsSinceUnixEpoch: Milliseconds

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

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

The nanosecond of the second.

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

The second of the Unix epoch.

secondsSinceUnixEpoch
Link copied to clipboard
common
open val secondsSinceUnixEpoch: Seconds

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

Extensions

at
Link copied to clipboard
common
infix fun Instant.at(offset: UtcOffset): OffsetDateTime

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

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

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

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

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

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

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

fun Instant.roundedDownToNearest(increment: Minutes): Instant

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

fun Instant.roundedDownToNearest(increment: Seconds): Instant

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

fun Instant.roundedDownToNearest(increment: Milliseconds): Instant

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

fun Instant.roundedDownToNearest(increment: Microseconds): Instant

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

fun Instant.roundedDownToNearest(increment: Nanoseconds): Instant

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

roundedTo
Link copied to clipboard
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
Link copied to clipboard
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.

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.

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.

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.

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.

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.

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

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

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

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

fun Instant.roundedUpToNearest(increment: Minutes): Instant

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

fun Instant.roundedUpToNearest(increment: Seconds): Instant

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

fun Instant.roundedUpToNearest(increment: Milliseconds): Instant

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

fun Instant.roundedUpToNearest(increment: Microseconds): Instant

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

fun Instant.roundedUpToNearest(increment: Nanoseconds): Instant

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

toDateAt
Link copied to clipboard
common
fun Instant.toDateAt(offset: UtcOffset): Date

Converts this instant to the corresponding Date at offset.

fun Instant.toDateAt(zone: TimeZone): Date

Converts this instant to the corresponding Date in zone.

toDateTimeAt
Link copied to clipboard
common
fun Instant.toDateTimeAt(offset: UtcOffset): DateTime

Converts this instant to the corresponding DateTime at offset.

fun Instant.toDateTimeAt(zone: TimeZone): DateTime

Converts this instant to the corresponding DateTime in zone.

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

Converts this instant to an equivalent Java Instant.

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

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

until
Link copied to clipboard
common
infix fun Instant.until(to: Instant): InstantInterval

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