[Git][java-team/jackson-modules-java8][master] 4 commits: New upstream version 2.23.0
Emmanuel Bourg (@ebourg)
gitlab at salsa.debian.org
Mon Nov 9 17:10:38 GMT 2026
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / jackson-modules-java8
Commits:
61b9a5bc by Emmanuel Bourg at 2026-11-09T17:07:43+01:00
New upstream version 2.23.0
- - - - -
f54c6ecc by Emmanuel Bourg at 2026-11-09T17:07:43+01:00
Update upstream source from tag 'upstream/2.23.0'
Update to upstream version '2.23.0'
with Debian dir 106293beedc9129014f737b2d3abc476de32fd01
- - - - -
768ebcd5 by Emmanuel Bourg at 2026-11-09T17:09:09+01:00
Tightened the dependencies on the other jackson packages
- - - - -
252eed24 by Emmanuel Bourg at 2026-11-09T17:27:28+01:00
Upload to unstable
- - - - -
24 changed files:
- .github/workflows/dep_build_v2.yml
- .github/workflows/dep_build_v3.yml
- .github/workflows/main.yml
- datatypes/pom.xml
- datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalTest.java
- datetime/README.md
- datetime/pom.xml
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeFeature.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DateTimeDeserializerBase.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializer.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/JSR310FormattedSerializerBase.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerializer.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java
- + datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/SubSecondFormatters.java
- datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerializer.java
- + datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/AlwaysWriteSubSecondDigits76Test.java
- debian/changelog
- debian/control
- parameter-names/pom.xml
- pom.xml
- release-notes/CREDITS-2.x
- release-notes/VERSION-2.x
Changes:
=====================================
.github/workflows/dep_build_v2.yml
=====================================
@@ -18,11 +18,11 @@ jobs:
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- - uses: actions/checkout at a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
+ - uses: actions/checkout at 3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: 2.x
- name: Set up JDK
- uses: actions/setup-java at 99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
+ uses: actions/setup-java at b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
=====================================
.github/workflows/dep_build_v3.yml
=====================================
@@ -18,11 +18,11 @@ jobs:
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- - uses: actions/checkout at a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
+ - uses: actions/checkout at 3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: 3.x
- name: Set up JDK
- uses: actions/setup-java at 99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
+ uses: actions/setup-java at b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
=====================================
.github/workflows/main.yml
=====================================
@@ -26,19 +26,19 @@ jobs:
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ - uses: actions/checkout at 3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK
- uses: actions/setup-java at 8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java at b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
cache: 'maven'
server-id: central-snapshots
- server-username: CI_DEPLOY_USERNAME
- server-password: CI_DEPLOY_PASSWORD
+ server-username-env-var: CI_DEPLOY_USERNAME
+ server-password-env-var: CI_DEPLOY_PASSWORD
# See https://github.com/actions/setup-java/blob/v2/docs/advanced-usage.md#Publishing-using-Apache-Maven
# gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
- # gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
+ # gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Build
run: ./mvnw -B -q -ff -ntp verify
- name: Extract project Maven version
@@ -56,7 +56,7 @@ jobs:
run: ./mvnw -B -q -ff -ntp test
- name: Publish code coverage
if: ${{ matrix.release_build && github.event_name != 'pull_request' }}
- uses: codecov/codecov-action at 015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
+ uses: codecov/codecov-action at 303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./target/site/jacoco/jacoco.xml
=====================================
datatypes/pom.xml
=====================================
@@ -9,7 +9,7 @@
<parent>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-modules-java8</artifactId>
- <version>2.22.4</version>
+ <version>2.23.0</version>
</parent>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
=====================================
datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalTest.java
=====================================
@@ -284,6 +284,7 @@ public class OptionalTest extends ModuleTestBase
}
// [modules-java8#372]
+ @Test
public void testIssue372Deser() throws Exception
{
JsonNode input = MAPPER.getNodeFactory().textNode("abc");
=====================================
datetime/README.md
=====================================
@@ -37,6 +37,8 @@ For TimeZone handling, `ADJUST_DATES_TO_CONTEXT_TIME_ZONE` (default: true) speci
'SerializedProvider#getTimeZone()' should be used to adjust Date/Time values on deserialization, even if the value itself
contains timezone information. The resultant ZoneId will be [normalized](https://docs.oracle.com/javase/8/docs/api/java/time/ZoneId.html#normalized--) where applicable. If the value is `OffsetDateTime.MIN` or `OffsetDateTime.MAX`, the Date/Time value will not be adjusted. If disabled, it will only be used if the value itself does not contain any TimeZone information.
+On serialization, `ObjectMapper`'s default TimeZone is UTC, but that default is **implicit** (`SerializationConfig.hasExplicitTimeZone()` is false until `ObjectMapper.setTimeZone(...)` or `ObjectWriter.with(TimeZone)` is called). `ZonedDateTime` and `OffsetDateTime` therefore keep the zone already on the value when written as ISO-8601 strings. `SerializationFeature.WRITE_DATES_WITH_CONTEXT_TIME_ZONE` (enabled by default since 2.13) only converts to the mapper TimeZone when that timezone was set explicitly. Calling `mapper.setTimeZone(TimeZone.getTimeZone("UTC"))` is enough to make UTC take effect for those types, except when the value is written with `SerializationFeature.WRITE_DATES_WITH_ZONE_ID` enabled (`ZonedDateTime` then always writes its own zone id) or with a `@JsonFormat` pattern whose formatter already carries a timezone of its own.
+
Finally, there are two features that apply to array handling. `UNWRAP_SINGLE_VALUE_ARRAYS` (default: false) allows auto-conversion from single-element arrays to non-JSON-array
values. If the JSON value contains more than one element in the array, deserialization will still fail. `ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT` (default: false) determines whether empty Array value ("[ ]" in JSON) is accepted
as null value for regular POJOs ("beans") with data-binding
=====================================
datetime/pom.xml
=====================================
@@ -9,7 +9,7 @@
<parent>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-modules-java8</artifactId>
- <version>2.22.4</version>
+ <version>2.23.0</version>
</parent>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeFeature.java
=====================================
@@ -51,7 +51,40 @@ public enum JavaTimeFeature implements JacksonFeature
*<p>
* Default setting is false, meaning that Month is serialized/deserialized as a zero-based index.
*/
- ONE_BASED_MONTHS(false)
+ ONE_BASED_MONTHS(false),
+
+ /**
+ * Feature that determines whether sub-second digits are always written when
+ * serializing {@link java.time.Instant}, {@link java.time.OffsetDateTime},
+ * {@link java.time.ZonedDateTime} and {@link java.time.LocalDateTime} <b>values</b>
+ * as ISO-8601 Strings using the default format.
+ *<p>
+ * When disabled (the default), the JDK-provided ISO formatters are used and
+ * a zero sub-second value is omitted altogether -- {@code 2017-09-14T04:28:48Z}
+ * -- which means that output width varies with the value, breaking systems
+ * that expect fixed-precision timestamps (or that sort timestamps as text).
+ *<p>
+ * When enabled, at least 3 (millisecond) sub-second digits are always written,
+ * zero-padded if necessary -- {@code 2017-09-14T04:28:48.000Z}. Higher precision
+ * is preserved: a value with microsecond or nanosecond precision is written with
+ * 6 or 9 digits respectively, so no information is lost.
+ *<p>
+ * Only affects the default format: an explicit {@code DateTimeFormatter} or
+ * a {@link com.fasterxml.jackson.annotation.JsonFormat} pattern takes precedence,
+ * as does writing values as numeric timestamps.
+ *<p>
+ * Also note that this only applies to values, and NOT to {@link java.util.Map}
+ * keys: date/time keys keep being written using the JDK-provided ISO formatters,
+ * so a zero sub-second value is still omitted there. Types other than the four
+ * listed above -- notably {@link java.time.LocalTime} and
+ * {@link java.time.OffsetTime}, whose ISO formats also omit the seconds field --
+ * are likewise unaffected.
+ *<p>
+ * Default setting is disabled, for backwards compatibility.
+ *
+ * @since 2.23
+ */
+ ALWAYS_WRITE_SUBSECOND_DIGITS(false)
;
/**
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java
=====================================
@@ -61,6 +61,11 @@ import com.fasterxml.jackson.datatype.jsr310.ser.key.ZonedDateTimeKeySerializer;
* local dates and times, periods, durations, zones, and more. All {@code java.time} types
* have built-in translation to and from ISO-8601 formats.
* <p>
+ * Note that {@code ObjectMapper}'s default TimeZone of UTC is <em>implicit</em>, and as such
+ * does not override the zone already on {@link ZonedDateTime} and {@link OffsetDateTime}
+ * values written as ISO-8601 Strings: see
+ * {@link com.fasterxml.jackson.datatype.jsr310.ser.InstantSerializerBase} for details.
+ * <p>
* Granularity of timestamps is controlled through the companion features
* {@link com.fasterxml.jackson.databind.SerializationFeature#WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS} and
* {@link com.fasterxml.jackson.databind.DeserializationFeature#READ_DATE_TIMESTAMPS_AS_NANOSECONDS}. For serialization, timestamps are
@@ -157,12 +162,12 @@ public final class JavaTimeModule
JavaTimeSerializers sers = new JavaTimeSerializers();
sers.addSerializer(Duration.class, DurationSerializer.INSTANCE);
- sers.addSerializer(Instant.class, InstantSerializer.INSTANCE);
- sers.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE);
+ sers.addSerializer(Instant.class, InstantSerializer.INSTANCE.withFeatures(_features));
+ sers.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE.withFeatures(_features));
sers.addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE);
sers.addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE);
sers.addSerializer(MonthDay.class, MonthDaySerializer.INSTANCE);
- sers.addSerializer(OffsetDateTime.class, OffsetDateTimeSerializer.INSTANCE);
+ sers.addSerializer(OffsetDateTime.class, OffsetDateTimeSerializer.INSTANCE.withFeatures(_features));
sers.addSerializer(OffsetTime.class, OffsetTimeSerializer.INSTANCE);
sers.addSerializer(Period.class, new ToStringSerializer(Period.class));
sers.addSerializer(Year.class, YearSerializer.INSTANCE);
@@ -173,7 +178,7 @@ public final class JavaTimeModule
* serialization with timezone offset only, not timezone id.
* But this is configurable.
*/
- sers.addSerializer(ZonedDateTime.class, ZonedDateTimeSerializer.INSTANCE);
+ sers.addSerializer(ZonedDateTime.class, ZonedDateTimeSerializer.INSTANCE.withFeatures(_features));
// since 2.11: need to override Type Id handling
// (actual concrete type is `ZoneRegion`, but that's not visible)
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DateTimeDeserializerBase.java
=====================================
@@ -27,7 +27,7 @@ public abstract class JSR310DateTimeDeserializerBase<T>
protected final DateTimeFormatter _formatter;
/**
- * Setting that indicates the {@Link JsonFormat.Shape} specified for this deserializer
+ * Setting that indicates the {@link JsonFormat.Shape} specified for this deserializer
* as a {@link com.fasterxml.jackson.annotation.JsonFormat.Shape} annotation on
* property or class, or due to per-type "config override", or from global settings:
* If Shape is NUMBER_INT, the input value is considered to be epoch days. If not a
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializer.java
=====================================
@@ -22,6 +22,10 @@ import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import com.fasterxml.jackson.core.util.JacksonFeatureSet;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
+
/**
* Serializer for Java 8 temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
*
@@ -34,10 +38,20 @@ public class InstantSerializer extends InstantSerializerBase<Instant>
public static final InstantSerializer INSTANCE = new InstantSerializer();
+ /**
+ * Whether {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS}
+ * is enabled: if so, the default representation is padded to at least 3 sub-second
+ * digits.
+ *
+ * @since 2.23
+ */
+ private final boolean _alwaysWriteSubsecondDigits;
+
protected InstantSerializer() {
super(Instant.class, Instant::toEpochMilli, Instant::getEpochSecond, Instant::getNano,
// null -> use 'value.toString()', default format
null);
+ _alwaysWriteSubsecondDigits = false;
}
@Deprecated // since 2.14
@@ -52,11 +66,63 @@ public class InstantSerializer extends InstantSerializerBase<Instant>
protected InstantSerializer(InstantSerializer base, Boolean useTimestamp,
DateTimeFormatter formatter, JsonFormat.Shape shape) {
super(base, useTimestamp, base._useNanoseconds, formatter, shape);
+ _alwaysWriteSubsecondDigits = base._alwaysWriteSubsecondDigits;
}
protected InstantSerializer(InstantSerializer base,
Boolean useTimestamp, Boolean useNanoseconds, DateTimeFormatter formatter) {
super(base, useTimestamp, useNanoseconds, formatter);
+ _alwaysWriteSubsecondDigits = base._alwaysWriteSubsecondDigits;
+ }
+
+ /**
+ * @since 2.23
+ */
+ protected InstantSerializer(InstantSerializer base, boolean alwaysWriteSubsecondDigits) {
+ super(base, base._useTimestamp, base._useNanoseconds, base._formatter, base._shape);
+ _alwaysWriteSubsecondDigits = alwaysWriteSubsecondDigits;
+ }
+
+ /**
+ * Method called by {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeModule}
+ * to apply module-level {@link JavaTimeFeature} settings.
+ *
+ * @since 2.23
+ */
+ public InstantSerializer withFeatures(JacksonFeatureSet<JavaTimeFeature> features) {
+ if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) {
+ return new InstantSerializer(this, true);
+ }
+ return this;
+ }
+
+ /**
+ * Overridden to implement
+ * {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS}
+ * by padding the default representation, instead of swapping in a different formatter.
+ *<p>
+ * Rationale: the default representation is {@link Instant#toString()}, that is,
+ * {@link DateTimeFormatter#ISO_INSTANT}, which writes exactly 0, 3, 6 or 9 sub-second
+ * digits -- so the only case needing a fix is the zero one. Formatting through a
+ * zone-bound {@code DateTimeFormatter} instead would resolve the value via
+ * {@link java.time.LocalDateTime}, whose year range is narrower than that of
+ * {@code Instant}, and would thereby fail for {@link Instant#MIN} / {@link Instant#MAX}.
+ *
+ * @since 2.23
+ */
+ @Override
+ protected String formatValue(Instant value, SerializerProvider provider)
+ {
+ String formatted = super.formatValue(value, provider);
+ // Only applies to the default representation: an explicit formatter wins
+ if (_alwaysWriteSubsecondDigits && (_formatter == null) && (value.getNano() == 0)) {
+ final int last = formatted.length() - 1;
+ // Defensive: `ISO_INSTANT` always ends in 'Z', but do not corrupt output if not
+ if ((last >= 0) && (formatted.charAt(last) == 'Z')) {
+ formatted = formatted.substring(0, last) + ".000Z";
+ }
+ }
+ return formatted;
}
@Override
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java
=====================================
@@ -42,13 +42,29 @@ import com.fasterxml.jackson.datatype.jsr310.DecimalUtils;
/**
* Base class for serializers used for {@link java.time.Instant} and
* other {@link Temporal} subtypes.
+ * <p>
+ * When writing ISO-8601 Strings, the context {@link java.util.TimeZone} is applied
+ * only if all of the following hold:
+ * <ul>
+ * <li>the TimeZone was set explicitly -- that is,
+ * {@code SerializationConfig.hasExplicitTimeZone()} returns {@code true}, which it does
+ * only after {@code ObjectMapper.setTimeZone()} or {@code ObjectWriter.with(TimeZone)}
+ * has been called; {@code ObjectMapper}'s documented default of UTC is
+ * <em>implicit</em> and does NOT count
+ * </li>
+ * <li>{@link com.fasterxml.jackson.databind.SerializationFeature#WRITE_DATES_WITH_CONTEXT_TIME_ZONE}
+ * is enabled (it is, by default, since 2.13)
+ * </li>
+ * <li>the {@link DateTimeFormatter} in use does not already have a zone of its own
+ * (as it may, for example, when configured via {@code @JsonFormat})
+ * </li>
+ * </ul>
+ * Otherwise the zone (or offset) already on the value being written is retained as-is.
*/
@SuppressWarnings("serial")
public abstract class InstantSerializerBase<T extends Temporal>
extends JSR310FormattedSerializerBase<T>
{
- private final DateTimeFormatter defaultFormat;
-
private final ToLongFunction<T> getEpochMillis;
private final ToLongFunction<T> getEpochSeconds;
@@ -61,8 +77,7 @@ public abstract class InstantSerializerBase<T extends Temporal>
{
// Bit complicated, just because we actually want to "hide" default formatter,
// so that it won't accidentally force use of textual presentation
- super(supportedType, null);
- this.defaultFormat = defaultFormat;
+ super(supportedType, null, defaultFormat);
this.getEpochMillis = getEpochMillis;
this.getEpochSeconds = getEpochSeconds;
this.getNanoseconds = getNanoseconds;
@@ -86,7 +101,18 @@ public abstract class InstantSerializerBase<T extends Temporal>
protected InstantSerializerBase(InstantSerializerBase<T> base, Boolean useTimestamp,
Boolean useNanoseconds, DateTimeFormatter dtf, JsonFormat.Shape shape) {
super(base, useTimestamp, useNanoseconds, dtf, shape);
- defaultFormat = base.defaultFormat;
+ getEpochMillis = base.getEpochMillis;
+ getEpochSeconds = base.getEpochSeconds;
+ getNanoseconds = base.getNanoseconds;
+ }
+
+ /**
+ * @since 2.23
+ */
+ protected InstantSerializerBase(InstantSerializerBase<T> base,
+ DateTimeFormatter defaultFormat)
+ {
+ super(base, defaultFormat);
getEpochMillis = base.getEpochMillis;
getEpochSeconds = base.getEpochSeconds;
getNanoseconds = base.getNanoseconds;
@@ -147,7 +173,7 @@ public abstract class InstantSerializerBase<T extends Temporal>
// @since 2.12
protected String formatValue(T value, SerializerProvider provider)
{
- DateTimeFormatter formatter = (_formatter == null) ? defaultFormat :_formatter;
+ DateTimeFormatter formatter = (_formatter == null) ? _defaultFormat :_formatter;
if (formatter != null) {
if (formatter.getZone() == null) { // timezone set if annotated on property
// If the user specified to use the context TimeZone explicitly, and the formatter provided doesn't contain a TZ
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/JSR310FormattedSerializerBase.java
=====================================
@@ -65,6 +65,18 @@ abstract class JSR310FormattedSerializerBase<T>
*/
protected final DateTimeFormatter _formatter;
+ /**
+ * Format to use when no explicit {@link #_formatter} is configured. Unlike
+ * {@code _formatter}, a non-null value here does NOT force serialization as a
+ * JSON String -- which is exactly why the two cannot be collapsed into one.
+ *<p>
+ * May be {@code null}, in which case the sub-class decides the fallback
+ * (typically either a JDK {@code ISO_*} constant or {@code value.toString()}).
+ *
+ * @since 2.23
+ */
+ protected final DateTimeFormatter _defaultFormat;
+
protected final JsonFormat.Shape _shape;
/**
@@ -81,13 +93,22 @@ abstract class JSR310FormattedSerializerBase<T>
protected JSR310FormattedSerializerBase(Class<T> supportedType,
DateTimeFormatter formatter) {
+ this(supportedType, formatter, null);
+ }
+
+ /**
+ * @since 2.23
+ */
+ protected JSR310FormattedSerializerBase(Class<T> supportedType,
+ DateTimeFormatter formatter, DateTimeFormatter defaultFormat) {
super(supportedType);
_useTimestamp = null;
_useNanoseconds = null;
_shape = null;
_formatter = formatter;
+ _defaultFormat = defaultFormat;
}
-
+
protected JSR310FormattedSerializerBase(JSR310FormattedSerializerBase<?> base,
Boolean useTimestamp, DateTimeFormatter dtf, JsonFormat.Shape shape)
{
@@ -103,6 +124,27 @@ abstract class JSR310FormattedSerializerBase<T>
_useNanoseconds = useNanoseconds;
_formatter = dtf;
_shape = shape;
+ _defaultFormat = base._defaultFormat;
+ }
+
+ /**
+ * Copy-constructor used for replacing the default format -- and only that --
+ * of an existing serializer; needed for
+ * {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS}.
+ * Note that the replacement must NOT be passed as {@code _formatter}, since a
+ * non-null {@code _formatter} also forces serialization as a JSON String.
+ *
+ * @since 2.23
+ */
+ protected JSR310FormattedSerializerBase(JSR310FormattedSerializerBase<?> base,
+ DateTimeFormatter defaultFormat)
+ {
+ super(base.handledType());
+ _useTimestamp = base._useTimestamp;
+ _useNanoseconds = base._useNanoseconds;
+ _formatter = base._formatter;
+ _shape = base._shape;
+ _defaultFormat = defaultFormat;
}
protected abstract JSR310FormattedSerializerBase<?> withFormat(Boolean useTimestamp,
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerializer.java
=====================================
@@ -25,8 +25,10 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.WritableTypeId;
+import com.fasterxml.jackson.core.util.JacksonFeatureSet;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
/**
* Serializer for Java 8 temporal {@link LocalDateTime}s.
@@ -39,13 +41,13 @@ public class LocalDateTimeSerializer extends JSR310FormattedSerializerBase<Local
private static final long serialVersionUID = 1L;
public static final LocalDateTimeSerializer INSTANCE = new LocalDateTimeSerializer();
-
+
protected LocalDateTimeSerializer() {
this(null);
}
public LocalDateTimeSerializer(DateTimeFormatter f) {
- super(LocalDateTime.class, f);
+ super(LocalDateTime.class, f, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}
// protected in 2.14 (from private)
@@ -53,13 +55,33 @@ public class LocalDateTimeSerializer extends JSR310FormattedSerializerBase<Local
super(base, useTimestamp, useNanoseconds, f, null);
}
+ /**
+ * @since 2.23
+ */
+ protected LocalDateTimeSerializer(LocalDateTimeSerializer base, DateTimeFormatter defaultFormat) {
+ super(base, defaultFormat);
+ }
+
+ /**
+ * Method called by {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeModule}
+ * to apply module-level {@link JavaTimeFeature} settings.
+ *
+ * @since 2.23
+ */
+ public LocalDateTimeSerializer withFeatures(JacksonFeatureSet<JavaTimeFeature> features) {
+ if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) {
+ return new LocalDateTimeSerializer(this, SubSecondFormatters.LOCAL_DATE_TIME);
+ }
+ return this;
+ }
+
@Override
protected JSR310FormattedSerializerBase<LocalDateTime> withFormat(Boolean useTimestamp, DateTimeFormatter f, JsonFormat.Shape shape) {
return new LocalDateTimeSerializer(this, useTimestamp, _useNanoseconds, f);
}
protected DateTimeFormatter _defaultFormatter() {
- return DateTimeFormatter.ISO_LOCAL_DATE_TIME;
+ return _defaultFormat;
}
@Override
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java
=====================================
@@ -4,6 +4,9 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
+import com.fasterxml.jackson.core.util.JacksonFeatureSet;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
+
public class OffsetDateTimeSerializer extends InstantSerializerBase<OffsetDateTime>
{
private static final long serialVersionUID = 1L;
@@ -35,6 +38,27 @@ public class OffsetDateTimeSerializer extends InstantSerializerBase<OffsetDateTi
super(base, useTimestamp, base._useNanoseconds, formatter, shape);
}
+ /**
+ * @since 2.23
+ */
+ protected OffsetDateTimeSerializer(OffsetDateTimeSerializer base,
+ DateTimeFormatter defaultFormat) {
+ super(base, defaultFormat);
+ }
+
+ /**
+ * Method called by {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeModule}
+ * to apply module-level {@link JavaTimeFeature} settings.
+ *
+ * @since 2.23
+ */
+ public OffsetDateTimeSerializer withFeatures(JacksonFeatureSet<JavaTimeFeature> features) {
+ if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) {
+ return new OffsetDateTimeSerializer(this, SubSecondFormatters.OFFSET_DATE_TIME);
+ }
+ return this;
+ }
+
/**
* Method for constructing a new {@code OffsetDateTimeSerializer} with settings
* of this serializer but with custom {@link DateTimeFormatter} overrides.
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/SubSecondFormatters.java
=====================================
@@ -0,0 +1,91 @@
+package com.fasterxml.jackson.datatype.jsr310.ser;
+
+import java.time.chrono.IsoChronology;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.format.ResolverStyle;
+import java.time.temporal.ChronoField;
+
+/**
+ * Container for the ISO-8601 {@link DateTimeFormatter}s used in place of the
+ * JDK-provided defaults when
+ * {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS}
+ * is enabled.
+ *<p>
+ * These differ from the JDK counterparts only in the sub-second field: instead of
+ * omitting it when zero, at least 3 (millisecond) digits are always written, and up
+ * to 9 when the value carries higher precision (so nothing is truncated). They are
+ * otherwise built the same way -- including {@link ResolverStyle#STRICT} and the ISO
+ * chronology -- so that they remain drop-in replacements even though they are only
+ * ever used for printing here.
+ *<p>
+ * Note that there is deliberately no counterpart of {@link DateTimeFormatter#ISO_INSTANT}
+ * here: formatting an {@link java.time.Instant} through a zone-bound formatter goes via
+ * {@link java.time.LocalDateTime}, whose year range is narrower than {@code Instant}'s,
+ * so {@link java.time.Instant#MIN} / {@link java.time.Instant#MAX} would fail. See
+ * {@link InstantSerializer#formatValue} for the handling used instead.
+ *
+ * @since 2.23
+ */
+class SubSecondFormatters
+{
+ private SubSecondFormatters() { }
+
+ /**
+ * Date and time down to the seconds field, followed by 3 to 9 sub-second digits:
+ * the shared prefix of all formatters here.
+ */
+ private static DateTimeFormatterBuilder _localDateTimeBuilder() {
+ return new DateTimeFormatterBuilder()
+ .append(DateTimeFormatter.ISO_LOCAL_DATE)
+ .appendLiteral('T')
+ .appendValue(ChronoField.HOUR_OF_DAY, 2)
+ .appendLiteral(':')
+ .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
+ .appendLiteral(':')
+ .appendValue(ChronoField.SECOND_OF_MINUTE, 2)
+ .appendFraction(ChronoField.NANO_OF_SECOND, 3, 9, true);
+ }
+
+ /**
+ * {@link #_localDateTimeBuilder()} followed by the offset: the shared prefix of the
+ * offset- and zone-based formatters.
+ */
+ private static DateTimeFormatterBuilder _offsetDateTimeBuilder() {
+ return _localDateTimeBuilder().appendOffsetId();
+ }
+
+ /**
+ * Completes a builder the way the JDK completes its own {@code ISO_*} constants.
+ *<p>
+ * Note that {@link DateTimeFormatterBuilder#toFormatter()} alone would yield
+ * {@link ResolverStyle#SMART} and no chronology, which is not what the constants
+ * these replace do.
+ */
+ private static DateTimeFormatter _isoFormatter(DateTimeFormatterBuilder b) {
+ return b.toFormatter()
+ .withResolverStyle(ResolverStyle.STRICT)
+ .withChronology(IsoChronology.INSTANCE);
+ }
+
+ /**
+ * Counterpart of {@link DateTimeFormatter#ISO_LOCAL_DATE_TIME}.
+ */
+ final static DateTimeFormatter LOCAL_DATE_TIME = _isoFormatter(_localDateTimeBuilder());
+
+ /**
+ * Counterpart of {@link DateTimeFormatter#ISO_OFFSET_DATE_TIME}.
+ */
+ final static DateTimeFormatter OFFSET_DATE_TIME = _isoFormatter(_offsetDateTimeBuilder());
+
+ /**
+ * Counterpart of {@link DateTimeFormatter#ISO_ZONED_DATE_TIME}, that is,
+ * {@link #OFFSET_DATE_TIME} with the optional {@code [Zone/Id]} suffix.
+ */
+ final static DateTimeFormatter ZONED_DATE_TIME = _isoFormatter(_offsetDateTimeBuilder()
+ .optionalStart()
+ .appendLiteral('[')
+ .parseCaseSensitive()
+ .appendZoneRegionId()
+ .appendLiteral(']'));
+}
=====================================
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerializer.java
=====================================
@@ -7,8 +7,10 @@ import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.util.JacksonFeatureSet;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
public class ZonedDateTimeSerializer extends InstantSerializerBase<ZonedDateTime> {
private static final long serialVersionUID = 1L;
@@ -21,7 +23,21 @@ public class ZonedDateTimeSerializer extends InstantSerializerBase<ZonedDateTime
* @since 2.8
*/
protected final Boolean _writeZoneId;
-
+
+ /**
+ * Formatter to use instead of {@link DateTimeFormatter#ISO_ZONED_DATE_TIME} when
+ * writing the zone id along with the value; {@code null} for the default.
+ *<p>
+ * Separate from the inherited {@code _defaultFormat} on purpose: writing with the
+ * zone id is a second output shape that has always used {@code ISO_ZONED_DATE_TIME}
+ * regardless of the default format (including a custom one passed to
+ * {@link #ZonedDateTimeSerializer(DateTimeFormatter)}), so the two cannot be
+ * collapsed without changing existing behaviour.
+ *
+ * @since 2.23
+ */
+ protected final DateTimeFormatter _zoneIdFormat;
+
protected ZonedDateTimeSerializer() {
// ISO_ZONED_DATE_TIME is an extended version of ISO compliant format
// ISO_OFFSET_DATE_TIME with additional information :Zone Id
@@ -34,6 +50,7 @@ public class ZonedDateTimeSerializer extends InstantSerializerBase<ZonedDateTime
ZonedDateTime::toEpochSecond, ZonedDateTime::getNano,
formatter);
_writeZoneId = null;
+ _zoneIdFormat = null;
}
protected ZonedDateTimeSerializer(ZonedDateTimeSerializer base,
@@ -56,6 +73,31 @@ public class ZonedDateTimeSerializer extends InstantSerializerBase<ZonedDateTime
JsonFormat.Shape shape, Boolean writeZoneId) {
super(base, useTimestamp, useNanoseconds, formatter, shape);
_writeZoneId = writeZoneId;
+ _zoneIdFormat = base._zoneIdFormat;
+ }
+
+ /**
+ * @since 2.23
+ */
+ protected ZonedDateTimeSerializer(ZonedDateTimeSerializer base,
+ DateTimeFormatter defaultFormat, DateTimeFormatter zoneIdFormat) {
+ super(base, defaultFormat);
+ _writeZoneId = base._writeZoneId;
+ _zoneIdFormat = zoneIdFormat;
+ }
+
+ /**
+ * Method called by {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeModule}
+ * to apply module-level {@link JavaTimeFeature} settings.
+ *
+ * @since 2.23
+ */
+ public ZonedDateTimeSerializer withFeatures(JacksonFeatureSet<JavaTimeFeature> features) {
+ if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) {
+ return new ZonedDateTimeSerializer(this,
+ SubSecondFormatters.OFFSET_DATE_TIME, SubSecondFormatters.ZONED_DATE_TIME);
+ }
+ return this;
}
@Override
@@ -89,7 +131,7 @@ public class ZonedDateTimeSerializer extends InstantSerializerBase<ZonedDateTime
; // use default handling
} else if (shouldWriteWithZoneId(provider)) {
// write with zone
- g.writeString(DateTimeFormatter.ISO_ZONED_DATE_TIME.format(value));
+ g.writeString(_zoneIdFormatter().format(value));
return;
}
}
@@ -110,6 +152,13 @@ public class ZonedDateTimeSerializer extends InstantSerializerBase<ZonedDateTime
return formatted;
}
+ /**
+ * @since 2.23
+ */
+ protected DateTimeFormatter _zoneIdFormatter() {
+ return (_zoneIdFormat == null) ? DateTimeFormatter.ISO_ZONED_DATE_TIME : _zoneIdFormat;
+ }
+
/**
* @since 2.8
*/
=====================================
datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/AlwaysWriteSubSecondDigits76Test.java
=====================================
@@ -0,0 +1,203 @@
+package com.fasterxml.jackson.datatype.jsr310.ser;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.Locale;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests for [modules-java8#76]: {@link JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS}.
+ */
+public class AlwaysWriteSubSecondDigits76Test extends ModuleTestBase
+{
+ static class Wrapper {
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
+ public OffsetDateTime value;
+
+ Wrapper(OffsetDateTime v) { value = v; }
+ }
+
+ static class ShapeOnlyWrapper {
+ @JsonFormat(shape = JsonFormat.Shape.STRING)
+ public Instant value;
+
+ ShapeOnlyWrapper(Instant v) { value = v; }
+ }
+
+ // NOTE: cannot use `ModuleTestBase.mapperBuilder()` here, since it already registers a
+ // plain `JavaTimeModule` and duplicate registrations of the same module are ignored
+ private static JsonMapper.Builder builderWithFeature() {
+ return JsonMapper.builder()
+ .defaultLocale(Locale.ENGLISH)
+ .addModule(new JavaTimeModule()
+ .enable(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS));
+ }
+
+ private final ObjectMapper MAPPER = builderWithFeature()
+ .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .build();
+
+ private final ObjectMapper DEFAULT_MAPPER = mapperBuilder()
+ .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .build();
+
+ @Test
+ public void testInstantZeroSubSecond() throws Exception
+ {
+ Instant value = Instant.parse("2017-09-14T04:28:48Z");
+ // Default: sub-second field omitted entirely
+ assertEquals(q("2017-09-14T04:28:48Z"), DEFAULT_MAPPER.writeValueAsString(value));
+ // Enabled: zero-padded to millisecond precision
+ assertEquals(q("2017-09-14T04:28:48.000Z"), MAPPER.writeValueAsString(value));
+ }
+
+ @Test
+ public void testInstantHigherPrecisionNotTruncated() throws Exception
+ {
+ assertEquals(q("2017-09-14T04:28:48.100Z"),
+ MAPPER.writeValueAsString(Instant.parse("2017-09-14T04:28:48.100Z")));
+ assertEquals(q("2017-09-14T04:28:48.123456Z"),
+ MAPPER.writeValueAsString(Instant.parse("2017-09-14T04:28:48.123456Z")));
+ assertEquals(q("2017-09-14T04:28:48.123456789Z"),
+ MAPPER.writeValueAsString(Instant.parse("2017-09-14T04:28:48.123456789Z")));
+ }
+
+ @Test
+ public void testOffsetDateTime() throws Exception
+ {
+ OffsetDateTime value = OffsetDateTime.parse("2017-09-14T04:28:48+02:00");
+ assertEquals(q("2017-09-14T04:28:48+02:00"), DEFAULT_MAPPER.writeValueAsString(value));
+ assertEquals(q("2017-09-14T04:28:48.000+02:00"), MAPPER.writeValueAsString(value));
+
+ // Note: the JDK ISO formatter renders 100 msec as ".1"; with the feature on,
+ // width is stable at (at least) 3 digits
+ OffsetDateTime millis = OffsetDateTime.parse("2017-09-14T04:28:48.100+02:00");
+ assertEquals(q("2017-09-14T04:28:48.1+02:00"), DEFAULT_MAPPER.writeValueAsString(millis));
+ assertEquals(q("2017-09-14T04:28:48.100+02:00"), MAPPER.writeValueAsString(millis));
+ }
+
+ @Test
+ public void testZonedDateTime() throws Exception
+ {
+ ZonedDateTime value = ZonedDateTime.parse("2017-09-14T04:28:48+02:00[Europe/Budapest]");
+ assertEquals(q("2017-09-14T04:28:48.000+02:00"), MAPPER.writeValueAsString(value));
+ }
+
+ @Test
+ public void testZonedDateTimeWithZoneId() throws Exception
+ {
+ ObjectMapper mapper = builderWithFeature()
+ .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID)
+ .build();
+ ZonedDateTime value = ZonedDateTime.parse("2017-09-14T04:28:48+02:00[Europe/Budapest]");
+ assertEquals(q("2017-09-14T04:28:48.000+02:00[Europe/Budapest]"),
+ mapper.writeValueAsString(value));
+ }
+
+ @Test
+ public void testLocalDateTime() throws Exception
+ {
+ LocalDateTime value = LocalDateTime.parse("2017-09-14T04:28:48");
+ assertEquals(q("2017-09-14T04:28:48"), DEFAULT_MAPPER.writeValueAsString(value));
+ assertEquals(q("2017-09-14T04:28:48.000"), MAPPER.writeValueAsString(value));
+
+ // Seconds keep being written even when zero (as with the JDK ISO formatter)
+ LocalDateTime noSeconds = LocalDateTime.parse("2017-09-14T04:28");
+ assertEquals(q("2017-09-14T04:28:00"), DEFAULT_MAPPER.writeValueAsString(noSeconds));
+ assertEquals(q("2017-09-14T04:28:00.000"), MAPPER.writeValueAsString(noSeconds));
+ }
+
+ // Feature must not leak into numeric timestamp serialization
+ @Test
+ public void testTimestampsUnaffected() throws Exception
+ {
+ ObjectMapper mapper = builderWithFeature()
+ .enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .build();
+ assertEquals("1505363328.000000000",
+ mapper.writeValueAsString(Instant.parse("2017-09-14T04:28:48Z")));
+ }
+
+ // ... nor override an explicit `@JsonFormat` pattern
+ @Test
+ public void testExplicitPatternWins() throws Exception
+ {
+ assertEquals(a2q("{'value':'2017-09-14T04:28:48'}"),
+ MAPPER.writeValueAsString(new Wrapper(OffsetDateTime.parse("2017-09-14T04:28:48Z"))));
+ }
+
+ // Values written with the feature on must still be readable
+ @Test
+ public void testRoundTrip() throws Exception
+ {
+ for (String raw : new String[] {
+ "2017-09-14T04:28:48Z", "2017-09-14T04:28:48.123456789Z",
+ "1970-01-01T00:00:00Z", "+10000-09-14T04:28:48Z", "-0100-09-14T04:28:48Z" }) {
+ Instant value = Instant.parse(raw);
+ String json = MAPPER.writeValueAsString(value);
+ assertEquals(value, MAPPER.readValue(json, Instant.class),
+ "Round-trip failed for " + raw + " (serialized as " + json + ")");
+ }
+ }
+
+ // The full `Instant` range must keep working: it is wider than that of
+ // `LocalDateTime`, so the feature must not route `Instant` through a
+ // zone-bound formatter
+ @Test
+ public void testInstantMinMax() throws Exception
+ {
+ // no sub-second part -> padded
+ assertEquals(q("-1000000000-01-01T00:00:00Z"),
+ DEFAULT_MAPPER.writeValueAsString(Instant.MIN));
+ assertEquals(q("-1000000000-01-01T00:00:00.000Z"),
+ MAPPER.writeValueAsString(Instant.MIN));
+
+ // already at nanosecond precision -> unchanged
+ assertEquals(q("+1000000000-12-31T23:59:59.999999999Z"),
+ DEFAULT_MAPPER.writeValueAsString(Instant.MAX));
+ assertEquals(q("+1000000000-12-31T23:59:59.999999999Z"),
+ MAPPER.writeValueAsString(Instant.MAX));
+
+ // and just inside the `LocalDateTime` boundary, either side
+ assertEquals(q("-999999999-01-01T00:00:00.000Z"),
+ MAPPER.writeValueAsString(LocalDateTime.MIN.toInstant(ZoneOffset.UTC)));
+ assertEquals(q("-1000000000-12-31T23:59:59.000Z"),
+ MAPPER.writeValueAsString(LocalDateTime.MIN.toInstant(ZoneOffset.UTC).minusSeconds(1)));
+ }
+
+ // `Instant.toString()` writes 0, 3, 6 or 9 sub-second digits; only the
+ // zero case may be rewritten, the rest must be passed through untouched
+ @Test
+ public void testInstantSubSecondWidthsPreserved() throws Exception
+ {
+ assertEquals(q("1970-01-01T00:00:00.000000001Z"),
+ MAPPER.writeValueAsString(Instant.ofEpochSecond(0, 1)));
+ assertEquals(q("1970-01-01T00:00:00.000001Z"),
+ MAPPER.writeValueAsString(Instant.ofEpochSecond(0, 1000)));
+ assertEquals(q("1970-01-01T00:00:00.001Z"),
+ MAPPER.writeValueAsString(Instant.ofEpochSecond(0, 1000000)));
+ }
+
+ // `@JsonFormat(shape=STRING)` without a pattern must not lose the padding
+ @Test
+ public void testShapeStringWithoutPattern() throws Exception
+ {
+ assertEquals(a2q("{'value':'2017-09-14T04:28:48.000Z'}"),
+ MAPPER.writeValueAsString(new ShapeOnlyWrapper(Instant.parse("2017-09-14T04:28:48Z"))));
+ }
+}
=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+jackson-modules-java8 (2.23.0-1) unstable; urgency=medium
+
+ * Team upload.
+ * New upstream release
+ - Tightened the dependencies on the other jackson packages
+
+ -- Emmanuel Bourg <ebourg at apache.org> Mon, 09 Nov 2026 17:27:28 +0100
+
jackson-modules-java8 (2.22.4-1) unstable; urgency=medium
* Team upload.
=====================================
debian/control
=====================================
@@ -8,9 +8,9 @@ Build-Depends:
maven-debian-helper (>= 2.6),
Build-Depends-Indep:
libbuild-helper-maven-plugin-java,
- libjackson2-annotations-java (>= 2.22),
- libjackson2-core-java (>= 2.22.4),
- libjackson2-databind-java (>= 2.22.4),
+ libjackson2-annotations-java (>= 2.23),
+ libjackson2-core-java (>= 2.23.0),
+ libjackson2-databind-java (>= 2.23.0),
libmaven-bundle-plugin-java,
libmaven-shade-plugin-java,
libreplacer-java,
=====================================
parameter-names/pom.xml
=====================================
@@ -9,7 +9,7 @@
<parent>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-modules-java8</artifactId>
- <version>2.22.4</version>
+ <version>2.23.0</version>
</parent>
<artifactId>jackson-module-parameter-names</artifactId>
<name>Jackson-module-parameter-names</name>
=====================================
pom.xml
=====================================
@@ -3,12 +3,12 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
- <version>2.22.4</version>
+ <version>2.23.0</version>
</parent>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-modules-java8</artifactId>
<name>Jackson modules: Java 8</name>
- <version>2.22.4</version>
+ <version>2.23.0</version>
<packaging>pom</packaging>
<description>Parent pom for Jackson modules needed to support Java 8 features and types
</description>
@@ -24,7 +24,7 @@
<connection>scm:git:git at github.com:FasterXML/jackson-modules-java8.git</connection>
<developerConnection>scm:git:git at github.com:FasterXML/jackson-modules-java8.git</developerConnection>
<url>http://github.com/FasterXML/jackson-modules-java8</url>
- <tag>jackson-modules-java8-2.22.4</tag>
+ <tag>jackson-modules-java8-2.23.0</tag>
</scm>
<issueManagement>
<url>https://github.com/FasterXML/jackson-modules-java8/issues</url>
=====================================
release-notes/CREDITS-2.x
=====================================
@@ -234,3 +234,12 @@ Boleslav Bobcik (@bbobcik)
Albert Lovers (@AlbertLovers)
* Reported, contributed fix for #381: Fix a potential problem in `JavaTimeModule._findFactory()`
(2.21.0)
+
+Ryan (@rycler)
+ * Reported #76: Missing milliseconds, when serializing Java 8 date-time, if they are zeros
+ (2.23.0)
+
+Seonwoo Jung (@seonwooj0810)
+ * Contributed fix for #76: Missing milliseconds, when serializing Java 8 date-time,
+ if they are zeros
+ (2.23.0)
=====================================
release-notes/VERSION-2.x
=====================================
@@ -8,6 +8,13 @@ Modules:
=== Releases ===
------------------------------------------------------------------------
+2.23.0 (07-Nov-2026)
+
+#76: Missing milliseconds, when serializing Java 8 date-time if they are zeros (Add
+ `JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS`)
+ (reported by @rycler)
+ (fix contributed by Seonwoo J)
+
2.22.4 (17-Oct-2026)
2.22.3 (21-Sep-2026)
2.22.2 (16-Aug-2026)
View it on GitLab: https://salsa.debian.org/java-team/jackson-modules-java8/-/compare/02759cbd79a2063fba08d53a3baa84690fb603e8...252eed2406ed108c177abf6ec5987c7a3a218c3c
--
View it on GitLab: https://salsa.debian.org/java-team/jackson-modules-java8/-/compare/02759cbd79a2063fba08d53a3baa84690fb603e8...252eed2406ed108c177abf6ec5987c7a3a218c3c
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20261109/59030a78/attachment.htm>
More information about the pkg-java-commits
mailing list