I'm trying to parse a date string using Java8 LocalDateTime without any success.
The exception is: DateTimeParseException: Text '28-APR-2015 01:25:00 PM' could not be parsed at index 3
The string to parse is: 28-APR-2015 01:25:00 PM and the pattern I'm currently using is dd-LLL-yyyy hh:mm:ss a
Where am I wrong?
Thank you
Adding example code:
String text = "28-APR-2015 01:25:00 PM";
DateTimeFormatter fromatter = DateTimeFormatter.ofPattern("dd-LLL-yyyy hh:mm:ss a");
try {
String out = LocalDateTime.parse(text, formatter)
System.out.println(out);
} catch (DateTimeParseException e) {
e.printStackTrace();
}
Solved using the response from @Florin using:
DateTimeFormatter tertiaryFormatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive().parseLenient().appendPattern("dd-LLL-yyyy hh:mm:ss a").toFormatter();