I am trying to parse JSON as local date, I tried multiple options including @jsonFormat but I am still getting the below exception - (I am using spring boot rest controller for accepting this request)
public class Student {
private long rollNumber;
private String firstName;
private String lastName;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
private LocalDate dob;
private Gender gender;
private Grade grade;
}
json :
[{
"rollNumber":"1",
"firstName":"abc",
"lastName":"ere",
"dob":"08-06-1993",
"gender":"MALE",
"grade":"TENTH"
}]
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.time.LocalDate` from String \"08-06-1993\": Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '08-06-1993' could not be parsed at index 0; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDate` from String \"08-06-1993\": Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '08-06-1993' could not be parsed at index 0\n at [Source: (PushbackInputStream); line: 5, column: 7] (through reference chain: java.util.ArrayList[0]->com.example.application.restApp.model.Student[\"dob\"])\r\n\tat org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:389)\r\n\tat org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:342)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:185)\r\n\tat