I have a Spring Boot application (2.4.1), where an OffsetDateTime
field is returned as float value from RestController
. Example:
"created_at": 1616080724.531610100
I tried all the suggested solutions in this thread. None of them worked for me.
I also tried to add a very simple end-point that only returns OffsetDateTime
:
@GetMapping("/test")
public OffsetDateTime test() {
return OffsetDateTime.now();
}
The result is the same, it's returned as float value.
Then I tried the same end-point in a minimal Spring Boot project and it's returned in ISO format as expected:
"2021-03-18T15:39:14.5295632+01:00"
This all points to some transitive dependency messing up with the default Jackson serializers used by Sprint Boot. But mvn dependency:tree
doesn't give me any suspicious dependencies (e.g. no gson marshaller dependency).
I also tried enabling TRACE logging, and I can see that the object written in HttpEntityMethodProcessor
has the correctly formatted created_at
time:
TRACE org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor - Writing [class MyObject {
....
createdAt: 2021-03-18T16:37:34.113316500+01:00
...
But it still ends up as float on the client side (testing on browser and with Postman). What could be the problem here?