title: Set MongoDb converter programmatically
body: <p>I'm trying to use a custom converter with spring-data-mongodb. I want to create it programmatically, but I get the following error:</p>
  
  <pre><code>org.springframework.core.convert.ConverterNotFoundException: No converter found capable of     converting from type org.joda.time.LocalDate to type java.lang.String
  at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:475)
  at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:175)
  at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:154)
  ....
  ....
  </code></pre>
  
  <p>The following is the failing code snippet:</p>
  
  <pre><code>    Mongo mongo = new Mongo();
      MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongo, "database");
  
      List&lt;Converter&gt; converters = new ArrayList&lt;&gt;();
      converters.add(new LocalDateWriteConverter());
      converters.add(new LocalDateReadConverter());
      CustomConversions customConversions = new CustomConversions(converters);
  
      MappingContext mappingContext = new SimpleMongoMappingContext();
      MappingMongoConverter mappingMongoConverter = new MappingMongoConverter(mongoDbFactory, mappingContext);
      mappingMongoConverter.setCustomConversions(customConversions);
  
      MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory, mappingMongoConverter);
  
      MongoDbEvent mongoEvent = new MongoDbEvent(new LocalDate(2012, 12, 8));
      mongoTemplate.insert(mongoEvent);
  </code></pre>
  
  <p>And here are my converter classes:</p>
  
  <pre><code>class LocalDateReadConverter implements Converter&lt;String, LocalDate&gt; {
      @Override
      public LocalDate convert(String s) {
          // Conversion code omitted.
      }
  }
  
  class LocalDateWriteConverter implements Converter&lt;LocalDate, String&gt; {
  
      @Override
      public String convert(LocalDate localDate) {
          // Conversion code omitted.
      }
  }
  </code></pre>
  
  <p>The class I'm trying to persist looks like this:</p>
  
  <pre><code>import org.joda.time.LocalDate;
  
  public class MongoDbEvent {
  
      private String id;
      private LocalDate date;
  
      public MongoDbEvent(LocalDate date) {
          this.date = date;
      }
  
      public String getId() {
          return id;
      }
  
      public LocalDate getDate() {
          return date;
      }
  
      @Override
      public String toString() {
          return "MongoDbEvent{" +
                  "id='" + id + '\'' +
                  ", date=" + date +
                  '}';
          }
  }
  </code></pre>