However, when I implement what I think is exactly as suggested, my XmlAdapter (LocalDateAdapter) (unmarshal & marshal) class never gets called.
When I do a GET from my RestController, my java.time.LocalDateTime gets formatted in JSON as follows:
I always get the following error when doing a POST:
at [Source: java.io.PushbackInputStream@1fd4d283; line: 1, column: 8] (through reference chain: com.jobs.spring.domain.Employee["joiningDate"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class java.time.LocalDateTime] from String value ('2016-07-04 12:24:19'); no single-String constructor/factory method
This is my model class's entry:
This is my Spring config:
I have also tried package-info.java with no success.
I write a unit test that calls the XmlAdapter (LocalDateTimeAdapter) successfully.
But I am a little confused how to configure the equivalent to my runtime. i.e. How to wire this in Spring for it to get invoked when the RESTful service is called. Does the JAXBContext need to be registered somehow?
Is there any other configuration I need to do to make it aware of the LocalDateAdapter class?
(I am using Java 8 and Spring 4.3.1)
A teeny tiny vulgar attempt to get you to buy our stuff
Free, earth friendly heat - from the CodeRanch trailboss