Disable SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS by default

See gh-19352
pull/19540/head
Filip Hrisafov 5 years ago committed by Stephane Nicoll
parent 2171e7a425
commit bb5c151ee0

@ -88,6 +88,7 @@ public class JacksonAutoConfiguration {
static {
Map<Object, Boolean> featureDefaults = new HashMap<>();
featureDefaults.put(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
featureDefaults.put(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false);
FEATURE_DEFAULTS = Collections.unmodifiableMap(featureDefaults);
}

@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jackson;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
@ -378,6 +379,15 @@ class JacksonAutoConfigurationTests {
});
}
@Test
void writeDurationAsTimestampsDefault() {
this.contextRunner.run((context) -> {
ObjectMapper mapper = context.getBean(ObjectMapper.class);
Duration duration = Duration.ofHours(2);
assertThat(mapper.writeValueAsString(duration)).isEqualTo("\"PT2H\"");
});
}
@Test
void writeWithVisibility() {
this.contextRunner

Loading…
Cancel
Save