OffsetDateTime class Absolute times
A date and time at a fixed offset from UTC.
- Implemented types
- Annotations
-
- @immutable
Constructors
- OffsetDateTime(int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int nanosecond = 0])
-
Constructs an
OffsetDateTimefrom the individual components of a date and time.factory - OffsetDateTime.fromDateTime(DateTime dateTime)
-
Constructs an
OffsetDateTimefrom aDateTime. - OffsetDateTime.fromInstant(HasInstant hasInstant, [ZoneOffset? offset])
-
Constructs an
OffsetDateTimefrom anInstant. - OffsetDateTime.fromLocalDateTime(LocalDateTime dt, [ZoneOffset? offset])
-
Constructs an
OffsetDateTimefrom aLocalDateTime.factory - OffsetDateTime.fromUnix(Timespan unixTimestamp, [ZoneOffset? offset])
-
Constructs an
OffsetDateTimefrom an unix timestamp and a fixed offset from UTC. - OffsetDateTime.now()
-
Constructs an
OffsetDateTimewith the current date and time. - OffsetDateTime.parse(String isoString)
-
Parses an
OffsetDateTimefrom an ISO-8601 formatted string.factory - OffsetDateTime.withOffset(ZoneOffset offset, int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int nanosecond = 0])
-
Constructs an
OffsetDateTimefrom an offset and the individual components of the date and time.const
Properties
- day → int
-
The day starting at 1.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- hour → int
-
The hour from 0 to 23.
no setterinherited
- inLeapYear → bool
-
Determines if this date falls in a leap year.
no setterinherited
- minute → int
-
The minute from 0 to 59.
no setterinherited
- month → int
-
The month from 1 to 12.
no setterinherited
- nanosecond → int
-
The nanoseconds from 0 to 999,999,999.
no setterinherited
- offset → ZoneOffset
-
The amount the time zone is offset from UTC.
final
- ordinalDay → int
-
The number of days since the beginning of the year.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → int
-
The second from 0 to 59.
no setterinherited
- unixTimestamp → Timespan
-
The amount of time since midnight, January 1, 1970 UTC.
no setteroverride
- weekday → Weekday
-
The day of the week.
no setterinherited
- year → int
-
The year.
no setterinherited
Methods
-
atOffset(
[ZoneOffset? offset]) → OffsetDateTime -
Converts this to an OffsetDateTime with the given offset.
inherited
-
compareTo(
HasInstant other) → int -
Compares this to another
HasInstant.inherited -
format(
DateFormat format) → String -
Formats this object using the given format.
inherited
-
inTimezone(
[String? zoneId]) → ZonedDateTime -
Converts this to a ZonedDateTime in the time zone given by
zoneId.inherited -
minusPeriod(
Period period) → OffsetDateTime -
minusTimespan(
Timespan timespan) → OffsetDateTime -
Subtracts a
Timespan. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
periodUntil(
HasDate date) → Period - Finds the Period between this and another HasDate.
-
plusPeriod(
Period period) → OffsetDateTime -
plusTimespan(
Timespan timespan) → OffsetDateTime -
Adds a
Timespan. -
quantize(
RelativeTime amount) → OffsetDateTime -
Rounds this to a value divisible by
amount. -
replace(
{int? year, int? month, int? day, int? hour, int? minute, int? second, int? nanosecond, ZoneOffset? offset}) → OffsetDateTime - Returns a new datetime with one or more fields replaced.
-
timespanUntil(
HasInstant other) → Timespan -
Finds the amount of time between this and another instant in time.
inherited
-
toDateTime(
) → DateTime - Converts this to a DateTime in the local time zone.
-
toInstant(
) → Instant - Converts this to an Instant in UTC.
-
toLocal(
) → LocalDateTime -
Converts this to a
LocalDateTime. -
toString(
) → String - Formats this as an ISO 8601 date time with offset.
Operators
-
operator +(
RelativeTime amount) → OffsetDateTime -
Adds a
TimespanorPeriod. -
operator -(
RelativeTime amount) → OffsetDateTime -
Subtracts a
TimespanorPeriod. -
operator <(
HasInstant other) → bool -
Less than operator.
inherited
-
operator <=(
HasInstant other) → bool -
Less than or equals operator.
inherited
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
HasInstant other) → bool -
Greater than operator.
inherited
-
operator >=(
HasInstant other) → bool -
Greater than or equals operator.
inherited
Constants
- maximum → const OffsetDateTime
- The latest supported datetime.
- minimum → const OffsetDateTime
- The earliest supported datetime.