I have some questions related to JSON serialization using Jackson in a project where I use Spring Boot 2.0.0.M6
, Spring Framework 5.0.1.RELEASE
and Jackson 2.9.2
.
I have configured the following Jackson-related settings in application.properties
:
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
Serialization works mostly as I need. Nevertheless, I have noticed that Jackson seems to cut-off milliseconds if they are 000
.
Test 1: Serialize Instant with milliseconds set to 000
:
- Initialize Instant field using
Instant.parse("2017-09-14T04:28:48.000Z")
- Serialize it using Jackson
- Output will be
"2017-09-14T04:28:48Z"
Test 2: Serialize Instant with milliseconds set to some non-000
value:
- Initialize Instant field using
Instant.parse("2017-09-14T04:28:48.100Z")
- Serialize it using Jackson
- Output will be
"2017-09-14T04:28:48.100Z"
Questions:
- Is that behavior by design?
- Is there anything I can do to force serialization of
000
?