The issue is that you are serializing your bean with a custom Gson
object while the application is attempting to deserialize your JSON with a Jackson ObjectMapper
(within MappingJackson2HttpMessageConverter
).
If you open up your server logs, you should see something like
Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of java.util.Date from String value '2013-34-10-10:34:31': not a valid representation (error: Failed to parse Date value '2013-34-10-10:34:31': Can not parse date "2013-34-10-10:34:31": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
at [Source: java.io.StringReader@baea1ed; line: 1, column: 20] (through reference chain: com.spring.Bean["publicationDate"])
among other stack traces.
One solution is to set your Gson
date format to one of the above (in the stacktrace).
The alternative is to register your own MappingJackson2HttpMessageConverter
by configuring your own ObjectMapper
to have the same date format as your Gson
.