From 0fd1273ed97ebfd0d45390ded57f182eee3c51cf Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Fri, 28 Jul 2023 13:28:45 +0200 Subject: [PATCH] Update documentation regarding java.time type conversion. Closes #3482 Original pull request: #4460 --- src/main/asciidoc/reference/mapping.adoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/asciidoc/reference/mapping.adoc b/src/main/asciidoc/reference/mapping.adoc index dbaaf2dd7..2c9b243f2 100644 --- a/src/main/asciidoc/reference/mapping.adoc +++ b/src/main/asciidoc/reference/mapping.adoc @@ -350,6 +350,14 @@ You can add additional converters to the converter by overriding the `customConv MongoDB's native JSR-310 support can be enabled through `MongoConverterConfigurationAdapter.useNativeDriverJavaTimeCodecs()`. Also shown in the preceding example is a `LoggingEventListener`, which logs `MongoMappingEvent` instances that are posted onto Spring's `ApplicationContextEvent` infrastructure. +[TIP] +==== +.Java Time Types + +We recommend using MongoDB's native JSR-310 support via `MongoConverterConfigurationAdapter.useNativeDriverJavaTimeCodecs()` as described above as it is using an `UTC` based approach. +The default JSR-310 support for `java.time` types inherited from Spring Data Commons uses the local machine timezone as reference and should only be used for backwards compatibility. +==== + NOTE: `AbstractMongoClientConfiguration` creates a `MongoTemplate` instance and registers it with the container under the name `mongoTemplate`. The `base-package` property tells it where to scan for classes annotated with the `@org.springframework.data.mongodb.core.mapping.Document` annotation.