Closed dangmai closed 1 month ago
Might be related to threeten's implementation: https://github.com/ThreeTen/threetenbp/issues/67
Closing this one since it's on threeten side. For my particular use case I have to change the code to something like:
DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(
DateTimeFormatter.ofPattern(
"yyyy-MM-dd'T'HH:mm:ss"))
.appendOptional(new DateTimeFormatterBuilder().appendOffset("+HH:MM", "Z").toFormatter())
.appendOptional(new DateTimeFormatterBuilder().appendOffset("+HHMM", "Z").toFormatter())
.toFormatter();
@dangmai anyway, it does not look like they going to fix it. So I believe, I could fix this myself someday in the forked version (which is used by TeaVM).
I create a small repo to show this behavior here: https://github.com/dangmai/teavm-datetimeformatter-bug
In a nutshell, this code works when run directly in Java (
./gradlew run
in the repo above):The same code, after being generated by TeaVM to Javascript, does not work. The first string does parse correctly, but the second string fails with error
Uncaught Error: Text '2018-01-02T03:04:05+01:00' could not be parsed at index 19
.I've configured both TimeZone autodetect and added a few more locales, as can be seen here.
I've tried searching issues/discussions in this repo with keywords like
Timezone
andlocale
, but I didn't find any solution.Thank you!