Add DateTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS - #6151
Merged
cowtowncoder merged 7 commits intoAug 11, 2026
Conversation
Ports the 2.x JavaTimeFeature of the same name (modules-java8#386) to 3.x's ctxt.isEnabled(...) pattern already used by TRUNCATE_TO_MSECS_ON_WRITE, rather than the 2.x withFeatures(JacksonFeatureSet) module-setup wiring. When enabled, Instant/OffsetDateTime/ZonedDateTime/LocalDateTime always serialize with at least millisecond-precision sub-second digits instead of omitting the field when it's zero. Explicit formatters/patterns and numeric-timestamp serialization are unaffected.
DateTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS
Code Review ✅ ApprovedAdds DateTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS to ensure Instant, OffsetDateTime, ZonedDateTime, and LocalDateTime always serialize with zero-padded millisecond precision. No issues found. OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
DateTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS: when enabled,Instant,OffsetDateTime,ZonedDateTimeandLocalDateTimealways serialize with at least millisecond-precision sub-second digits (zero-padded), instead of the JDK-provided ISO formatters omitting the field entirely when it's zero.Fixes the same underlying issue as modules-java8#76, where e.g.
Instant.parse("2017-09-14T04:28:48.000Z")serializes as"2017-09-14T04:28:48Z"(no.000), breaking systems that expect fixed-width timestamps or that sort them lexicographically.This ports the 2.x feature of the same name added in modules-java8#386, adapted to 3.x's architecture:
JavaTimeModule.setupModule()callingwithFeatures(JacksonFeatureSet<JavaTimeFeature>)).ctxt.isEnabled(DateTimeFeature.XXX)pattern for date/time flags (seeTRUNCATE_TO_MSECS_ON_WRITE), so this follows that pattern instead — no changes needed toJavaTimeInitializer.Scope, matching the 2.x feature:
Instant,OffsetDateTime,ZonedDateTime,LocalDateTime.LocalTime/OffsetTimehave the same zero-fraction omission but are out of scope here, to match the ported feature's scope.Only affects the default (no explicit formatter) textual serialization path; an explicit
DateTimeFormatter/@JsonFormatpattern still wins, and numeric-timestamp serialization is unaffected.