DateTimeWithTimeZone class

A DateTime that retains the original time zone.

Normal DateTime converts any value to either UTC or local time zone of the device. This class retains the original time zone.

Year must be between 0000 and 9999.

Implemented types
Annotations
  • @sealed

Constructors

DateTimeWithTimeZone.fromDateTime(DateTime dateTime)
Constructs dateTimeWithTimeZone from DateTime.
factory
DateTimeWithTimeZone.fromMicrosecondsSinceEpoch(int microsecondsSinceEpochInUtc, [Timezone timezone = Timezone.utc])
Constructs dateTimeWithTimeZone from microseconds since epoch.
DateTimeWithTimeZone.utc(int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0])
Constructs dateTimeWithTimeZone from DateTime.
factory

Properties

day int
Day of the month (1 ... 31).
no setter
hashCode int
The hash code for this object.
no setteroverride
microsecondsSinceEpochInUtc int
Microseconds since epoch.
final
month int
Month of the year (1 ... 12).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timezone Timezone
Time zone.
final
year int
Year (0 ... 9999).
no setter

Methods

add(Duration duration) DateTimeWithTimeZone
The API is identical to DateTime.add.
compareTo(DateTimeWithTimeZone other) int
Compares this object to another object.
override
difference(DateTimeWithTimeZone other) Duration
The API is identical to DateTime.difference.
isAfter(DateTimeWithTimeZone dateTimeWithTimeZone) bool
The API is identical to DateTime.isAfter.
isBefore(DateTimeWithTimeZone dateTimeWithTimeZone) bool
The API is identical to DateTime.isBefore.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subtract(Duration duration) DateTimeWithTimeZone
The API is identical to DateTime.subtract.
toDateTime({bool utc = false}) DateTime
Constructs DateTime from this instance.
toIso8601String() String
Returns a string with format "yyyy-MM-ddTHH:mm:ss.mmmuuuZ"
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

epoch DateTimeWithTimeZone
final

Static Methods

now() DateTimeWithTimeZone
Returns the most precise available dateTimeWithTimeZone.
parse(String s) DateTimeWithTimeZone
Parses a dateTimeWithTimeZone with format "yyyy-MM-ddTHH:mm:ss.mmmuuuZ".
tryParse(String source) DateTimeWithTimeZone?
Parses a dateTimeWithTimeZone with format "yyyy-MM-ddTHH:mm:ss.mmmuuuZ".