I have a full ISO8601 string, which looks like this: 1989-08-16T00:00:00.000Z. How do I create instance of LocalDate from it using js-joda library?
When trying to parse it directly with LocalDate.parse(), I'm getting the following error:
DateTimeParseException: Text '1989-08-16T00:00:00.000Z' could not be parsed,
unparsed text found at index 10…
I know I can easily split the string at T character or parse it with vanilla Date and then create LocalDate from it, but is there a more simple method, that I can use to easily parse any ISO8601 compatible string to LocalDate?
First convert your date to Js Date object, then to LocalDate Object.
The
Date.parseconverts the ISO string to miliseconds and then converting it into JS Date. Eventually using the JS Date object to get LocalDate object.