I would like to send POST request from my client to my backend, and in the POJO I have two fields LocalDate and LocalDateTime as follows:
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd.MM.yyyy - hh:mm:ss")
private LocalDateTime createdTimestamp;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd.MM.yyyy")
private LocalDate expiredDate;
The client will send request with body like:
{
"expiredDate" : "01.01.2020",
"createdTimestamp" : "01.02.2020 - 10:10:10"
}
In the backend, however, I got an exception:
java.lang.NoSuchMethodError:
com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;
And if I leave the createdTimestamp
out of request's body then it worked. It seems that only the annotation @JsonDeserialize(using = LocalDateDeserializer.class)
worked, while the @JsonDeserialize(using = LocalDateTimeDeserializer.class)
did not work.
Does anyone have an idea why this happened?