I've implemented a rest controller method that receives an object at RequestBody param, which is a simple POJO (a dependency from another project).
public class SimplePOJO {
private Date productionDate;
private String description;
//getters and setters
}
The json I'm receiving it's like this:
{"description":"something","productionDate":"10/03/2020"}
When I try to call the rest service, I get the error:
2020-07-11 15:23:09.274 WARN 3008 --- [nio-8441-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type
java.util.Date
from String "10/03/2020": not a valid representation (error: Failed to parse Date value '10/03/2020': Cannot parse date "10/03/2020": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd")); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of typejava.util.Date
from String "10/03/2020": not a valid representation (error: Failed to parse Date value '10/03/2020': Cannot parse date "10/03/2020": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
Unfortunately, it's not possible to add JsonFormat annotation at the productionDate field at SimplePOJO. Is there any other way to accept date in format "dd/MM/yyyy" in my service?
Thank you!