title: Spring-Data-MongoDB: Failed to convert from type after upgrade to 2.0.7 with custom converter
body: <p>I just upgraded to Spring Boot 2.0.2 today and as part of that also to Spring-Data-MongoDB 2.0.7.</p>
  
  <p>I have the following entity:</p>
  
  <pre><code>@Document
  @Data
  public class User {
  private String username;
  private String password;
  private List&lt;String&gt; authorities;
  
      public User(String username, String password, List&lt;String&gt; authorities) {
          this.username = username;
          this.password = password;
          this.authorities = authorities;
      }
  }
  </code></pre>
  
  <p>In a test of mine I insert a new User using the following:</p>
  
  <pre><code>mongoTemplate.save(new User("testuser", "$2a$04$OuKj.lXzPxlwgr2Jy28E4ehHuxnVZ7BuL46qX9fd6vAijcDN6UeHe", Collections.singletonList("user")));
  </code></pre>
  
  <p>This worked perfectly when using Spring Boot 2.0.1 (respectively Spring-Data-MongoDB 2.0.6). With the upgraded Spring-Data-MongoDB version, I get the following error:</p>
  
  <pre><code>org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.time.ZonedDateTime] for value 'testuser'; nested exception is java.time.format.DateTimeParseException: Text 'testuser' could not be parsed at index 0
  
      at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:46)
      at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:191)
      at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174)
      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleWrite(MappingMongoConverter.java:849)
      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeSimpleInternal(MappingMongoConverter.java:829)
      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeProperties(MappingMongoConverter.java:488)
      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:462)
      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:436)
      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:391)
      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:86)
      at org.springframework.data.mongodb.core.MongoTemplate.toDocument(MongoTemplate.java:1070)
      at org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:1253)
      at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:1201)
      at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:1185)
  ....
  Caused by: java.time.format.DateTimeParseException: Text 'testuser' could not be parsed at index 0
      at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
      at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
      at java.time.ZonedDateTime.parse(ZonedDateTime.java:597)
      at at.riag.scanpay.config.MongoConfig$StringToZonedDateTime.convert(MongoConfig.java:34)
      at at.riag.scanpay.config.MongoConfig$StringToZonedDateTime.convert(MongoConfig.java:28)
      at org.springframework.core.convert.support.GenericConversionService$ConverterAdapter.convert(GenericConversionService.java:385)
      at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:40)
      ... 71 more
  </code></pre>
  
  <p>So it seems like, it wants to convert the <code>username</code> to a <code>ZonedDateTime</code>. The problem could be my MongoConfig, where I have custom converters for <code>ZonedDateTime</code>:</p>
  
  <pre><code>@Configuration
  public class MongoConfig {
  
      private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
  
      @Bean
      public MongoCustomConversions customConversions(){
          List&lt;Converter&lt;?,?&gt;&gt; converters = new ArrayList&lt;&gt;();
          converters.add(ZonedDateTimeToStringConverter.INSTANCE);
          converters.add(StringToZonedDateTime.INSTANCE);
          return new MongoCustomConversions(converters);
      }
  
      enum StringToZonedDateTime implements Converter&lt;String, ZonedDateTime&gt; {
  
          INSTANCE;
  
          @Override
          public ZonedDateTime convert(String source) {
              return ZonedDateTime.parse(source, dateTimeFormatter);
          }
      }
  
      enum ZonedDateTimeToStringConverter implements Converter&lt;ZonedDateTime, String&gt; {
  
          INSTANCE;
  
          @Override
          public String convert(ZonedDateTime source) {
              return dateTimeFormatter.format(source);
          }
      }
  }
  </code></pre>
  
  <p>These converters should not be used for a plain String of course but it seems that it is triggered when using the new Spring Data MongoDB version. Can anyone please point me to the problem I am having with my code or is there a problem with the latest version?</p>
  
  <p>Thanks in advance!</p>