I am trying to map a JSON to POJO using Jackson2 for my REST method. The DueDate attribute in my POJO is of type java.util.date. I read that Jackson will deserialize JSON to timestamp by default. I want this behavior only. However, Jackson is converting the dueDate attribute to Date in my case.
Could anyone help me how to make Jackson deserialize the dueDate as timestamp.
JSON here ...
{ "atr1": null, "atr2": null, "dueDate": "2018-07-11" }
POJO here ..
public class Sample {
private String atr1;
private String atr1;
private Date dueDate;
}
REST Api ...
public Response create(String json) {
ObjectMapper mapper = new ObjectMapper();
Sample sample1 = mapper.readValue(json,Sample.class);
}
Thanks
More details... the value type of DueDate when the method is called from the actual UI object is Timestamp
However, when the JSON is passed to REST for the method call, the type changes to Date.
I want it to be Timestamp type. Because of this the SQL query which uses the dueDate as parameter doesn't fetch value properly.