I have a String that look like this:
String str = "Jun 26th 2021, 04:30:15 pm NY";
I want to convert it to ZonedDateTime, for this I use DateTimeFormatterBuilder:
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("MMM dd'th' uuuu, h:mm:ss a z")
.toFormatter(Locale.US);
ZonedDateTime result = ZonedDateTime.parse(str, formatter);
but the parser is not happy with this format I got this error:
java.time.format.DateTimeParseException: Text 'Jun 26th 2021, 04:30:15 pm NY' could not be parsed at index 27
It seems that NY not covered by the z, any idea about this error please, also is there any trick to avoid 'th' in the parser ?