XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.2 RC2 (Moore)
    • Fix Version/s: None
    • Component/s: Mapping / Conversion
    • Labels:
      None

      Description

      Since there is no converter supplied for `ZonedDateTime`, developers using this Java 8 type always need to create these: 

      class ZonedDateTimeReadConverter : Converter<Date, ZonedDateTime>
      {
          override fun convert(date: Date): ZonedDateTime =
                  date.toInstant().atZone(ZoneOffset.UTC)
      }
       
      class ZonedDateTimeWriteConverter : Converter<ZonedDateTime, Date>
      { 
          override fun convert(zonedDateTime: ZonedDateTime) =
                  Date.from(zonedDateTime.toInstant()) 
      }
      

      And then they need to register these as custom conversions, for example in a Spring Boot Project using Spring Data MongoDb:

      @Configuration
      @EnableReactiveMongoRepositories
      class MongoConfiguration
      {
          @Bean
          fun customConversions(): MongoCustomConversions =
                  MongoCustomConversions(listOf(ZonedDateTimeReadConverter(),
                                                ZonedDateTimeWriteConverter()))
      }

      The framework could supply those instead and have them registered by default.

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            Herman Bovens Herman Bovens
            Last updater:
            Mark Paluch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: