0

I need to send a POST request with the following JSON body:

{
 "date": "2020-08-21"
}

The date field has java.sql.Date type. This request results in an error which says that it could not deserialize the given string "2020-08-21" to sql.Date. If I change the JSON by adding some kind of time:

{
 "date": "2020-08-21 00:00:00"
}

It works fine. However, I would like to be able to send only Date values without the time, and be able to convert it to sql.Date. Any ideas on how to work around this? I would really not like to use a String for date and then map it to Date. Are there better ways to do this?

  • 1
    Don't know if this helps. https://stackoverflow.com/questions/55227544/cannot-deserialize-value-of-type-java-util-date-from-string – Ben Aug 21 '20 at 07:47
  • 1
    Also, please consider https://stackoverflow.com/help/minimal-reproducible-example – Ben Aug 21 '20 at 07:49
  • Thank you a lot! The first link solved my problem. Just used a Jackson annotation for formatting. – Dulat Aldazharov Aug 21 '20 at 09:35

0 Answers0