Can not convert from String to LocalDate in java

Hello I here for a DateTimeFormatter problem with the language, let me introduce you:

  • I'm reading a CSV file with this String Format: "dd-MMM-yyyy" <--> "28-dic-2017"
  • Then i have to parse each string from a list to LocalDate to handle each with timeAPI methods.
  • When Executed it returns:

Exception in thread "main" java.time.format.DateTimeParseException: Text '28-dic-2017' could not be parsed at index 3 at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2051) at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1953) at java.base/java.time.LocalDate.parse(LocalDate.java:429) at com.examen.Presentation.Principal.parseDate(Principal.java:28) at com.examen.Presentation.Principal.main(Principal.java:19)

public static LocalDate parseDate(String fecha) {

    Locale loc = new Locale("es", "ES");
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MMM-yyyy", loc);
    LocalDate date = LocalDate.parse(fecha, formatter);

    return date;
}

I've got the same error trying different things and methods from locale and DateTimeFormatter don't even know what i was doing, but I think that this should work OBVIOUSLY NOT so please HELP!! Thank You!!



from Recent Questions - Stack Overflow https://ift.tt/3dPGvI0
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations