Closed dg76 closed 4 months ago
This was a recent change to CLDR data, replacing the whitespace before the AM
in US English time formatting with a narrow non-breaking space, so the behavior is correct. If you have a non-locale dependent time you would like to parse, try the FixedDateTimeFormatter.
If the use case is for a user to input a time, try to avoid using plain text fields, and use time pickers or similar instead, as parsing plain text fields is very brittle.
Describe the bug DateFormat.jm("en_US").parse("9:01 AM") causes the exception "FormatException: Trying to read from 9:01 AM at 5" instead of parsing the time. This has worked in intl 0.17.0 but does not work in 0.18.0, 0.18.1 or 0.19.0 any more. Tested with Dart 3.2.3 and 3.3.0.
To Reproduce
Output:
However, formatting and then parsing a time works fine:
Output:
There seems to be a special whitespace character between "9:01" and "AM" that causes this problem. But I suppose parsing a normal time like "9:01 AM" (e.g. from user input) should work anyway? Thank you for taking a look at this problem! :-)