parse method Null safety

TZDateTime parse(
  1. Location location,
  2. String formattedString
)
override

Constructs a new TZDateTime instance based on formattedString.

Throws a FormatException if the input cannot be parsed.

The function parses a subset of ISO 8601 which includes the subset accepted by RFC 3339.

The result is always in the time zone of the provided location.

Examples of accepted strings:

  • "2012-02-27 13:27:00"
  • "2012-02-27 13:27:00.123456z"
  • "20120227 13:27:00"
  • "20120227T132700"
  • "20120227"
  • "+20120227"
  • "2012-02-27T14Z"
  • "2012-02-27T14+00:00"
  • "-123450101 00:00:00 Z": in the year -12345.
  • "2002-02-27T14:00:00-0500": Same as "2002-02-27T19:00:00Z"

Implementation

static TZDateTime parse(Location location, String formattedString) {
  return TZDateTime.from(DateTime.parse(formattedString), location);
}