Skip to content
Advertisement

LocalDate.parse results in “DateTimeParseException…could not be parsed: null”

I am attempting to parse a date time stamp and extract only the date. Like so:

JavaScript

But this results in the following Exception:

JavaScript

This seems related to this issue: https://bugs.openjdk.java.net/browse/JDK-8226704. But the line numbers in my stack do not match up with those in the issue. Appreciate any pointers on what could be going wrong.

PS:

JavaScript

Advertisement

Answer

The ‘Z’ at the end there in your timestamp string? You get that with X in your pattern string. Not z. lower-case z in the format string means ‘time zone name’ and matches something like PST or Pacific Standard Time.

X is a shortened zone offset. something like -08 or Z.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement