Hi, I posted this as an issue on the Jackson Datatype Joda GitHub repo:
https://github.com/FasterXML/jackson-datatype-joda/issues/106 Also mailing the group for wider visibility. Spring Boot version: 1.4.3.RELEASE In my unit test I am having a problem with Joda DateTime values being serialized as numeric values instead of the expected ISO8601 date format. In application.properties I have the following: spring.jackson.date-format=com.fasterxml.jackson.databind.util.ISO8601DateFormat spring.jackson.joda-date-time-format=yyyy-MM-dd'T'HH:mm:ss'Z' spring.jackson.time-zone=org.joda.time.DateTimeZone.UTC spring.jackson.serialization.write-dates-as-timestamps=false When the application serializes a class with a variable of type Joda DateTime it is displayed as an integer, instead of using the ISO8601DateFormat. From the logs I can see that the properties above have been set: 2018-10-30 14:08:47.234 INFO 83415 --- [ main] c.y.a.c.r.TestPostCompanyResource : spring.jackson.date-format=com.fasterxml.jackson.databind.util.ISO8601DateFormat 2018-10-30 14:08:47.234 INFO 83415 --- [ main] c.y.a.c.r.TestPostCompanyResource : spring.jackson.joda-date-time-format=yyyy-MM-dd'T'HH:mm:ss'Z' 2018-10-30 14:08:47.234 INFO 83415 --- [ main] c.y.a.c.r.TestPostCompanyResource : spring.jackson.serialization.write-dates-as-timestamps=false 2018-10-30 14:08:47.234 INFO 83415 --- [ main] c.y.a.c.r.TestPostCompanyResource : spring.jackson.time-zone=org.joda.time.DateTimeZone.UTC However, the properties appear to be ignored at runtime. Stepping through the code in a debugger I see that in the method DateTimeSerializer.serialize(DateTime value, JsonGenerator gen, SerializerProvider provider) the call to method _useTimestamp(provider) is returning true instead of false: if (!writeWithZoneId(provider)) { // evaluates to true instead of false (as per write-dates-as-timestamps property) if (*_useTimestamp(provider)*) { gen.writeNumber(value.getMillis()); } else { gen.writeString(_format.createFormatter(provider).print(value)); } } else { The output from MockHttpServletResponse confirms this. The "events[0].time" and "lastUpdate" fields should be formatted as ISO8601 instead of numeric values: MockHttpServletResponse: Status = 202 Error message = null Headers = ... Content type = application/json Body = {"state":"accepted","message":"XXX","events":[{"state":"accepted","message":"XXX","time":1540908527416}],"lastUpdate":1540908527393} Forwarded URL = null Redirected URL = null Cookies = [] I've spent ages trying to figure out what is going on with no success - can anyone help please? Thanks, Charles. -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
