Add 2 new `JavaTimeFeature`s: for truncating Time values before serialization, after deserialization
(note: continuation of #374)
Existing features
DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDSSerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS
allow changing unit-of-time associated with numeric (JSON Number) timestamps b/w milliseconds (false) and nanoseconds (true), in cases where Time value has granularity beyond milliseconds. As a consequence, when disabled, precision is truncated to millisecond resolution.
These settings have no effect on textual (JSON String) representations, however.
It would be useful to have explicit features -- for this module, that'd be JavaTimeFeature (in 2.x -- in 3.x it'd be databind's new DateTimeFeature) -- like:
JavaTimeFeature.TRUNCATE_TO_MSECS_ON_READJavaTimeFeature.TRUNCATE_TO_MSECS_ON_WRITE
which would:
TRUNCATE_TO_MSECS_ON_READenabled: after reading Time value, clear nanoseconds part before returning to caller (affects Numeric timestamps too)TRUNCATE_TO_MSECS_ON_WRITEenabled: before writing Time value, clear nanoseconds part
These would alongside but independent @JsonFormat(pattern = ) configuration.
Open questions:
- Should this feature be added in 2.x (2.21) or only 3.x?
Given there is already way to handle expected behavior I think 3.x?
@JooHyukKim No, there is no truncation logic in 3.x either (aside from using @JsonFormat(pattern = ...) for serialization which is also available on 2.x).