Skip to content

Commit 8c7e0c6

Browse files
committed
Move Jackson datetime property beneath datatype
Closes gh-47327
1 parent 0b60111 commit 8c7e0c6

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/spring-mvc.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ These features are described in several enums (in Jackson) that map onto propert
6262
|===
6363
| Enum | Property | Values
6464

65+
| javadoc:tools.jackson.databind.cfg.DateTimeFeature[]
66+
| `spring.jackson.datatype.datetime.<feature_name>`
67+
| `true`, `false`
68+
6569
| javadoc:tools.jackson.databind.cfg.EnumFeature[]
6670
| `spring.jackson.datatype.enum.<feature_name>`
6771
| `true`, `false`
@@ -70,10 +74,6 @@ These features are described in several enums (in Jackson) that map onto propert
7074
| `spring.jackson.datatype.json-node.<feature_name>`
7175
| `true`, `false`
7276

73-
| javadoc:tools.jackson.databind.DateTimeFeature[]
74-
| `spring.jackson.datetime.<feature_name>`
75-
| `true`, `false`
76-
7777
| javadoc:tools.jackson.databind.DeserializationFeature[]
7878
| `spring.jackson.deserialization.<feature_name>`
7979
| `true`, `false`

module/spring-boot-jackson/src/main/java/org/springframework/boot/jackson/autoconfigure/JacksonAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void customize(JsonMapper.Builder builder) {
177177
configureFeatures(builder, this.jacksonProperties.getMapper(), builder::configure);
178178
configureFeatures(builder, this.jacksonProperties.getRead(), builder::configure);
179179
configureFeatures(builder, this.jacksonProperties.getWrite(), builder::configure);
180-
configureFeatures(builder, this.jacksonProperties.getDatetime(), builder::configure);
180+
configureFeatures(builder, this.jacksonProperties.getDatatype().getDatetime(), builder::configure);
181181
configureFeatures(builder, this.jacksonProperties.getDatatype().getEnum(), builder::configure);
182182
configureFeatures(builder, this.jacksonProperties.getDatatype().getJsonNode(), builder::configure);
183183
configureDateFormat(builder);

module/spring-boot-jackson/src/main/java/org/springframework/boot/jackson/autoconfigure/JacksonProperties.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ public class JacksonProperties {
9191
*/
9292
private final Map<JsonWriteFeature, Boolean> write = new EnumMap<>(JsonWriteFeature.class);
9393

94-
/**
95-
* Jackson on/off features for DateTime processing.
96-
*/
97-
private final Map<DateTimeFeature, Boolean> datetime = new EnumMap<>(DateTimeFeature.class);
98-
9994
/**
10095
* Controls the inclusion of properties during serialization. Configured with one of
10196
* the values in Jackson's JsonInclude.Include enumeration.
@@ -166,10 +161,6 @@ public Map<JsonWriteFeature, Boolean> getWrite() {
166161
return this.write;
167162
}
168163

169-
public Map<DateTimeFeature, Boolean> getDatetime() {
170-
return this.datetime;
171-
}
172-
173164
public JsonInclude.@Nullable Include getDefaultPropertyInclusion() {
174165
return this.defaultPropertyInclusion;
175166
}
@@ -251,6 +242,11 @@ public static class Datatype {
251242
*/
252243
private final Map<JsonNodeFeature, Boolean> jsonNode = new EnumMap<>(JsonNodeFeature.class);
253244

245+
/**
246+
* Jackson on/off features for DateTimes.
247+
*/
248+
private final Map<DateTimeFeature, Boolean> datetime = new EnumMap<>(DateTimeFeature.class);
249+
254250
public Map<EnumFeature, Boolean> getEnum() {
255251
return this.enumFeatures;
256252
}
@@ -259,6 +255,10 @@ public Map<JsonNodeFeature, Boolean> getJsonNode() {
259255
return this.jsonNode;
260256
}
261257

258+
public Map<DateTimeFeature, Boolean> getDatetime() {
259+
return this.datetime;
260+
}
261+
262262
}
263263

264264
}

module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/JacksonAutoConfigurationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void disableWriteFeature() {
266266

267267
@Test
268268
void enableDatetimeFeature() {
269-
this.contextRunner.withPropertyValues("spring.jackson.datetime.write-dates-as-timestamps:true")
269+
this.contextRunner.withPropertyValues("spring.jackson.datatype.datetime.write-dates-as-timestamps:true")
270270
.run((context) -> {
271271
JsonMapper mapper = context.getBean(JsonMapper.class);
272272
DateTimeFeature feature = DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS;
@@ -277,7 +277,8 @@ void enableDatetimeFeature() {
277277

278278
@Test
279279
void disableDatetimeFeature() {
280-
this.contextRunner.withPropertyValues("spring.jackson.datetime.adjust-dates-to-context-time-zone:false")
280+
this.contextRunner
281+
.withPropertyValues("spring.jackson.datatype.datetime.adjust-dates-to-context-time-zone:false")
281282
.run((context) -> {
282283
JsonMapper mapper = context.getBean(JsonMapper.class);
283284
assertThat(DateTimeFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE.enabledByDefault()).isTrue();

0 commit comments

Comments
 (0)