title: Spring DateTimeFormat Configuration for java.time
body: <p>I'm working on a Spring WebMvc (not Spring Boot) project that uses pure Java configuration for setting up its beans. I am having difficulty getting Spring/Jackson to respect the @DateTimeFormat annotation with java.time (jsr310) objects such as LocalDateTime.</p>
  
  <p>I have both jackson-datatype-jsr310 and jackson-databind jars (version 2.7.4) on the classpath, along with the relevant spring jars for a basic webmvc application spring-context and spring-webmvc (version 4.3.0.RELEASE)</p>
  
  <p>Here is my relevant configuration class:</p>
  
  <pre><code>@Configuration
  @ComponentScan({"com.example.myapp"})
  public class WebAppConfig extends WebMvcConfigurationSupport {
      @Override
      public void configureMessageConverters(List&lt;HttpMessageConverter&lt;?&gt;&gt; converters) {
          ObjectMapper mapper = Jackson2ObjectMapperBuilder
              .json()
              .indentOutput(true)
              .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
              .findModulesViaServiceLoader(true)
              .build();
  
          converters.add(new MappingJackson2HttpMessageConverter(mapper));
  
          super.addDefaultHttpMessageConverters(converters);
      }
  }
  </code></pre>
  
  <p>I've tested this with serializing my data models over a rest controller. Appears that Jackson is respecting @JsonFormat, but completely ignoring @DateTimeFormat.</p>
  
  <p>What additional configuration am I missing to get spring/jackson to respect @DateTimeFormat? Are there any key differences between the two annotations that I should be aware of, problems that I could run into just by using @JsonFormat?</p>