toString method

  1. @override
String toString()
override

Returns a ISO-8601 formatted string.

Format

The format is yyyy-MM-ddTHH:mm:ss.mmmuuuZ[identifier] for UTC time, and yyyy-MM-ddTHH:mm:ss.mmmuuu±hhmm[identifier] for local/non-UTC time, where:

  • yyyy is a, possibly negative, four digit representation of the year, if the year is in the range -9999 to 9999, otherwise it is a signed six digit representation of the year.
  • MM is the month in the range 01 to 12,
  • dd is the day of the month in the range 01 to 31,
  • HH are hours in the range 00 to 23,
  • mm are minutes in the range 00 to 59,
  • ss are seconds in the range 00 to 59 (no leap seconds),
  • mmm are milliseconds in the range 000 to 999, and
  • uuu are microseconds in the range 001 to 999. If microsecond equals 0, then this part is omitted.
  • identifier is a TZ database identifier.

Trailing zero-value seconds, milliseconds and microseconds are omitted.

Example

// 2023-04-30T12:15+08:00[Asia/Singapore]
print(ZonedDateTime('Asia/Singapore', 2023, 4, 30, 12, 15));

Implementation

@override
String toString() => _string ??= '${_native.toDateString()}T${_native.toTimeString()}${span.offset}[${timezone.name}]';