Skip to content

Commit 8dec443

Browse files
committed
Document default for MVC and WebFlux date and time formatting
Closes gh-30041
1 parent e7203e3 commit 8dec443

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/reactive.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ If you want to take complete control of Spring WebFlux, you can add your own `@C
4646

4747

4848

49+
[[web.reactive.webflux.conversion-service]]
50+
==== Spring WebFlux Conversion Service
51+
If you want to customize the `ConversionService` used by Spring WebFlux, you can provide a `WebFluxConfigurer` bean with an `addFormatters` method.
52+
53+
Conversion can also be customized using the `spring.webflux.format.*` configuration properties.
54+
When not configured, the following defaults are used:
55+
56+
|===
57+
|Property |`DateTimeFormatter`
58+
59+
|configprop:spring.webflux.format.date[]
60+
|`ofLocalizedDate(FormatStyle.SHORT)`
61+
62+
|configprop:spring.webflux.format.time[]
63+
|`ofLocalizedTime(FormatStyle.SHORT)`
64+
65+
|configprop:spring.webflux.format.date-time[]
66+
|`ofLocalizedDateTime(FormatStyle.SHORT)`
67+
|===
68+
69+
70+
4971
[[web.reactive.webflux.httpcodecs]]
5072
==== HTTP Codecs with HttpMessageReaders and HttpMessageWriters
5173
Spring WebFlux uses the `HttpMessageReader` and `HttpMessageWriter` interfaces to convert HTTP requests and responses.

spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,31 @@ If you want to provide custom instances of `RequestMappingHandlerMapping`, `Requ
4848

4949
If you want to take complete control of Spring MVC, you can add your own `@Configuration` annotated with `@EnableWebMvc`, or alternatively add your own `@Configuration`-annotated `DelegatingWebMvcConfiguration` as described in the Javadoc of `@EnableWebMvc`.
5050

51-
[NOTE]
52-
====
51+
52+
53+
[[web.servlet.spring-mvc.conversion-service]]
54+
==== Spring MVC Conversion Service
5355
Spring MVC uses a different `ConversionService` to the one used to convert values from your `application.properties` or `application.yaml` file.
5456
It means that `Period`, `Duration` and `DataSize` converters are not available and that `@DurationUnit` and `@DataSizeUnit` annotations will be ignored.
5557

5658
If you want to customize the `ConversionService` used by Spring MVC, you can provide a `WebMvcConfigurer` bean with an `addFormatters` method.
5759
From this method you can register any converter that you like, or you can delegate to the static methods available on `ApplicationConversionService`.
58-
====
60+
61+
Conversion can also be customized using the `spring.mvc.format.*` configuration properties.
62+
When not configured, the following defaults are used:
63+
64+
|===
65+
|Property |`DateTimeFormatter`
66+
67+
|configprop:spring.mvc.format.date[]
68+
|`ofLocalizedDate(FormatStyle.SHORT)`
69+
70+
|configprop:spring.mvc.format.time[]
71+
|`ofLocalizedTime(FormatStyle.SHORT)`
72+
73+
|configprop:spring.mvc.format.date-time[]
74+
|`ofLocalizedDateTime(FormatStyle.SHORT)`
75+
|===
5976

6077

6178

0 commit comments

Comments
 (0)