Skip to main content
Version: 0.1.0

Parsing

parse and tryParse read strings written in the same pattern syntax as format, including do ordinals and [literal] or 'literal' text, so formatting and parsing round-trip.

parse / tryParse​

  • strict: true rejects out-of-range values such as February 30.
  • utc: true returns a UTC DateTime.
  • tryParse returns null instead of throwing a FormatException.
  • Input is read in the formatter's locale: month and weekday names must be in that language. The sample input follows the locale selected in the dark bar.
LOADING…
⚙ TRY IT
⚡ OUTPUT
final formatter = FlutterDateFormatter('do MMMM yyyy', 'en');

formatter.parse('');
formatter.tryParse(''); // null instead of throwing
Ordinals

For do, the parser tries each ordinal suffix of the locale and keeps the result whose day actually takes that suffix, so 2st March is rejected.