@@ -313,9 +313,9 @@ work with date and time types.
313
313
kotlinx-datetime Library
314
314
~~~~~~~~~~~~~~~~~~~~~~~~
315
315
316
- ``kotlinx-datetime`` is a {+language+} library that allows
317
- you to work with dates and times. If you want a high level of control
318
- over how your date and time values are serialized, you can add the
316
+ ``kotlinx-datetime`` is a {+language+} library that offers
317
+ a high level of control over how your date and time values
318
+ are serialized. To use the library, add the ``kotlinx-datetime``
319
319
dependency to your project's dependency list.
320
320
321
321
Select from the following tabs to see how to add the ``kotlinx-datetime``
@@ -354,11 +354,17 @@ After you add the library dependency, you can implement serializers from
354
354
the ``kotlinx-datetime`` library that map your data class field values
355
355
to the expected types in BSON.
356
356
357
- The following ``Appointment`` data class has the ``@Serializable``
358
- annotation and the ``@Contextual`` annotation on the ``date`` field
359
- to use the ``kotlinx-datetime`` serializer for ``LocalDate`` values.
360
- Values of the ``time`` field are stored as strings, because the driver
361
- does not use a serializer without the ``@Contextual`` annotation:
357
+ In the following example, the driver serializes the fields of
358
+ the ``Appointment`` data class with the following behavior:
359
+
360
+ - ``name``: The driver serializes the value as a string.
361
+
362
+ - ``date``: The driver uses the ``kotlinx-datetime`` serializer
363
+ because the field has the ``@Contextual`` annotation. So,
364
+ ``LocalDate`` values are serialized as BSON dates.
365
+
366
+ - ``time``: The driver serializes the value as a string because it does
367
+ not have the ``@Contextual`` annotation.
362
368
363
369
.. literalinclude:: /examples/generated/KotlinXSerializationTest.snippet.datetime-data-class.kt
364
370
:language: kotlin
@@ -370,7 +376,7 @@ class into MongoDB:
370
376
:language: kotlin
371
377
372
378
In MongoDB, the ``LocalDate`` value is stored as a BSON date, and the
373
- ``time`` field is stored by using default serialization as a string:
379
+ ``time`` field is stored as a string by default serialization :
374
380
375
381
.. code-block:: json
376
382
0 commit comments