I need to parse a date in the following format in my Flutter application (come from JSON) :
2019-05-17T15:03:22.472+0000
According to the documentation, I have to use Z
to get the time zone (last 5 characters in RFC 822 format), so I use the following :
new DateFormat("y-M-d'T'H:m:s.SZ").parseStrict(json['startDate']);
But it fails with error :
FormatException: Characters remaining after date parsing in 2019-05-17T15:03:22.472+0000
Here is another test :
/// THIS WORKS
try {
print(new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(DateTime.now()));
} catch (e) {
print(e.toString());
}
/// THIS RETURNS `UnimplementedError` (as soon as I use a 'Z' or 'z') somewhere
try {
print(new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(DateTime.now()));
} catch (e) {
print(e.toString());
}
Is Z
implemented ?
Sadly z
and v
patterns are not implemented.
Those won't be implemented until Dart DateTime's have time zone information
More info on this issue https://github.com/dart-lang/intl/issues/19
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With