0

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.

Ritesh Waghela
  • 3,474
  • 2
  • 19
  • 25

1 Answers1

1

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?

Spring 3.1 JSON date format

Community
  • 1
  • 1
indybee
  • 1,507
  • 13
  • 17