Instant

Methods
24
Fields
3

Getting one

Instant.now()
Instant.ofEpochMilli(…)
Instant.ofEpochSecond(…)

Methods

MethodReturnsDescription
toEpochMilli()numberMilliseconds since the epoch; ArithmeticException past a long.
getEpochSecond()numberWhole seconds since the epoch (floored).
getNano()numberThe nano-of-second, 0 to 999,999,999.
plus(Duration)Instant(Instant, Duration) -> Instant: This instant plus a Duration.
plus(number, ChronoUnit | RSTimeUnit)Instant
minus(Duration)Instant(Instant, Duration) -> Instant: This instant less a Duration.
minus(number, ChronoUnit | RSTimeUnit)Instant
plusMillis(number)InstantPlus millisToAdd ms.
plusSeconds(number)InstantPlus secondsToAdd s.
plusNanos(number)InstantPlus nanosToAdd ns.
minusMillis(number)InstantLess millisToSubtract ms.
minusSeconds(number)InstantLess secondsToSubtract s.
minusNanos(number)InstantLess nanosToSubtract ns.
isAfter(Instant)booleanWhether this is after otherInstant.
isBefore(Instant)booleanWhether this is before otherInstant.
compareTo(Instant)numberThe seconds compared, then the nanos subtracted (which can answer other than -1, 0 and 1).
until_(Instant | LocalTime | LocalDate | LocalDateTime | ZonedDateTime, ChronoUnit | RSTimeUnit)numberThe amount of unit until endExclusive (an Instant or ZonedDateTime), truncated.
truncatedTo(ChronoUnit | RSTimeUnit)InstantThis instant truncated to unit (which must divide a day).
atZone(ZoneId)ZonedDateTimeThis instant in zone.
equals(any)booleanWhether other is an equal Instant.
hashCode()numberThe value's hash.
toString()stringISO-8601 in UTC, 2025-09-21T14:13:20.007Z.
now()InstantThe wall clock now.
ofEpochMilli(number)InstantThe instant epochMilli ms after 1970-01-01T00:00Z.
ofEpochSecond(number)Instant(number) -> Instant: The instant epochSecond s after 1970-01-01T00:00Z.
ofEpochSecond(number, number)Instant
parse(string)InstantDateTimeFormatter.ISO_INSTANT's text (2007-12-03T10:15:30.00Z, or an offset).

Fields

FieldTypeDescription
EPOCHInstant1970-01-01T00:00:00Z.
MINInstantThe earliest instant, -1000000000-01-01T00:00Z.
MAXInstantThe latest instant, 1000000000-12-31T23:59:59.999999999Z.

Returned by

MethodReturnsDescription
ChronoZonedDateTime.toInstantInstantThe instant.
Date.toInstantInstantDate#toInstant().
DiscordPresence.getEndTimestampInstant?When the activity ends.
DiscordPresence.getStartTimestampInstant?When the activity started.
InstantClass.nowInstantThe wall clock now.
InstantClass.ofEpochMilliInstantThe instant epochMilli ms after 1970-01-01T00:00Z.
InstantClass.ofEpochSecondInstant(number) -> Instant: The instant epochSecond s after 1970-01-01T00:00Z.
InstantClass.parseInstantDateTimeFormatter.ISO_INSTANT's text (2007-12-03T10:15:30.00Z, or an offset).
LoopTimer.getStartTimeInstantWhen it was made.
Timer.getEndTimeInstantWhen it runs out.
Timer.getStartTimeInstantWhen it was made.

Method details

toEpochMilli

toEpochMilli: (Instant) -> number

Milliseconds since the epoch; ArithmeticException past a long.

getNano

getNano: (Instant) -> number

The nano-of-second, 0 to 999,999,999.

plus

plus: ((Instant, Duration) -> Instant) & ((Instant, number, ChronoUnit | RSTimeUnit) -> Instant)

(Instant, Duration) -> Instant: This instant plus a Duration.

(Instant, number, ChronoUnit | RSTimeUnit) -> Instant: This instant plus amountToAdd of unit (NANOS to DAYS; a longer unit is unsupported, and an RSTimeUnit overflows the stack).

compareTo

compareTo: (Instant, Instant) -> number

The seconds compared, then the nanos subtracted (which can answer other than -1, 0 and 1).

equals

equals: (Instant, any) -> boolean

Whether other is an equal Instant.

toString

toString: (Instant) -> string

ISO-8601 in UTC, 2025-09-21T14:13:20.007Z.

ofEpochMilli

ofEpochMilli: (number) -> Instant

The instant epochMilli ms after 1970-01-01T00:00Z.

ofEpochSecond

ofEpochSecond: ((number) -> Instant) & ((number, number) -> Instant)

(number) -> Instant: The instant epochSecond s after 1970-01-01T00:00Z.

(number, number) -> Instant: The instant epochSecond s plus nanoAdjustment ns after the epoch.

parse

parse: (string) -> Instant

DateTimeFormatter.ISO_INSTANT's text (2007-12-03T10:15:30.00Z, or an offset).