I'm trying to parse only time ignoring weekday from the string with the following format: "Monday 5AM"
Here is my code:
String dateTxt = "Monday 5AM";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ha");
LocalTime lt = LocalTime.parse(dateTxt, formatter);
It throws an exception:
java.time.format.DateTimeParseException: Text 'Saturday 1AM' could not be parsed
How to parse only time from that string?