Instant class

Represents an instant on the global timeline, with nanosecond resolution.

An Instant has no concept of a particular time zone or calendar: it simply represents a point in time that can be globally agreed-upon.

This type is immutable.

Implemented types
Annotations
  • @immutable

Constructors

Instant()
factory
Instant.dateTime(DateTime dateTime)
factory
Instant.epochTime(Time time)
factory
Instant.fromEpochBigIntNanoseconds(BigInt nanoseconds)
factory
Instant.fromEpochMicroseconds(int microseconds)
factory
Instant.fromEpochMilliseconds(int milliseconds)
factory
Instant.fromEpochNanoseconds(int nanoseconds)
factory
Instant.fromEpochSeconds(int seconds)
note: these are much faster than calling Instant.epochTime
factory
Instant.julianDate(double julianDate)
factory
Instant.now()
Clock.getCurrentInstant for Clock.current.
factory
Instant.utc(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, [int secondOfMinute = 0])
factory

Properties

canEpochNanosecondsBeInteger bool
no setter
epochDay int
no setter
epochDayLocalTime LocalTime
no setter
epochDayTime Time
no setter
epochMicroseconds int
no setter
epochMilliseconds int
no setter
epochNanoseconds int
no setter
epochNanosecondsAsBigInt BigInt
no setter
epochSeconds int
no setter
hashCode int
The hash code for this object.
no setteroverride
isValid bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeSinceEpoch Time
final

Methods

add(Time time) Instant
compareTo(Instant other) int
Compares this object to another object.
override
inLocalZone([CalendarSystem? calendar]) ZonedDateTime
Get the ZonedDateTime that corresponds to this Instant within in the zone DateTimeZone.local.
inUtc() ZonedDateTime
inZone(DateTimeZone zone, [CalendarSystem? calendar]) ZonedDateTime
isAfter(Instant other) bool
isBefore(Instant other) bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subtract(Time time) Instant
timeSince(Instant instant) Time
The fluent opposite of timeUntil
timeUntil(Instant instant) Time
Calculates the time until this would become instant. this + Time = instant or start + Time = end
toDateTimeLocal() DateTime
toDateTimeUtc() DateTime
toJulianDate() double
toString([String? patternText, Culture? culture]) String
A string representation of this object.
override
toStringDDC([String? patternText, Culture? culture]) String
withOffset(Offset offset, [CalendarSystem? calendar]) OffsetDateTime

Operators

operator +(Time time) Instant
operator -(Time time) Instant
operator <(Instant other) bool
operator <=(Instant other) bool
operator ==(Object other) bool
The equality operator.
override
operator >(Instant other) bool
operator >=(Instant other) bool

Static Properties

maxValue Instant
Represents the largest possible Instant. This value is equivalent to 9999-12-31T23:59:59.999999999Z
final
minValue Instant
Represents the smallest possible Instant. This value is equivalent to -9998-01-01T00:00:00Z
final

Static Methods

difference(Instant start, Instant end) Time
max(Instant x, Instant y) Instant
min(Instant x, Instant y) Instant
minus(Instant x, Time y) Instant
plus(Instant x, Time y) Instant

Constants

unixEpoch → const Instant