Reputation: 3727
I am using spring framework and working on REST web services. One of my rest service insert/updates the date time value stored in one of the column of the my MySQL database table. The type I am using is datetime. My JSON request looks like:
{
"userId": "1",
"dateOfBirth": "1987-02-06 15:53:12",
}
Spring has been configured to use Jackson as message converter. dateOfBirth field in java object is of type java.util.Date. Problem I am facing is when I hit the rest service with the above json request, the request becomes Bad request. I think it is related to date time conversion, jackson is not able to covert it to a date object. Any help will be appreciated.
Upvotes: 0
Views: 954
Reputation: 1736
Can try creating customer serializer/deserailzer by extending JsonSerializer and JsonDeserializer classes, and then annotate the date field with them, see these 2 posts:
How to deserialize JS date using Jackson?
Upvotes: 1