I'm trying to parse a date String in this format: "18-Feb-23". The month is in German. I've tried this:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d-LLL-yy", Locale.GERMAN);
LocalDate.parse(row.soldDate,formatter),
but I get this exception:
Caused by: java.time.format.DateTimeParseException: Text '18-Feb-23' could not be parsed at index 0
I also tried d-MMM-yy but that doesn't work.
Just tried out your code, works fine for me
public void func () {
String date = "18-Mai-23";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d-LLL-yy", Locale.GERMAN);
LocalDate localDate = LocalDate.parse(date,formatter);
System.out.println(localDate);
}
Here is the output
2023-05-18
Its very hard to guess from what you have shared but I think the string that is going to the date formatter in your case is impure . That is it contains some characters (that might not even be visible in output window) which are messing things up. Here are things you can try