Configure MappingJackson2HttpMessageConverter by using java-configuration
<p>I am trying to configure MappingJackson2HttpMessageConverter because I want to disable the WRITE_DATES_TO_TIMESTAMP feature.</p>

<p>If I configure it by xml-configuration it works successfully</p>

<pre><code>&lt;bean name="jacksonObjectMapper"
    class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"&gt;
    &lt;property name="featuresToDisable"&gt;
        &lt;array&gt;
            &lt;util:constant
                static-field="com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS" /&gt;
        &lt;/array&gt;
    &lt;/property&gt;
&lt;/bean&gt;
&lt;mvc:annotation-driven&gt;
    &lt;mvc:message-converters register-defaults="true"&gt;
        &lt;bean
            class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&gt;
            &lt;property name="objectMapper" ref="jacksonObjectMapper" /&gt;
        &lt;/bean&gt;
    &lt;/mvc:message-converters&gt;
&lt;/mvc:annotation-driven&gt;
</code></pre>

<p>But when I try to configure through java-configuration the converter is registered but the serialization ignores the configuration of the mapper.</p>

<p>I have tried different aproaches.</p>

<p>Approach 1</p>

<pre><code>@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void configureMessageConverters(List&lt;HttpMessageConverter&lt;?&gt;&gt; converters) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    converters.add(new MappingJackson2HttpMessageConverter(mapper));
}
}
</code></pre>

<p>Approach 2</p>

<pre><code>@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void extendMessageConverters(List&lt;HttpMessageConverter&lt;?&gt;&gt; converters) {
    for (HttpMessageConverter&lt;?&gt; converter : converters) {
        if (converter instanceof MappingJackson2HttpMessageConverter) {
        MappingJackson2HttpMessageConverter jacksonMessageConverter = (MappingJackson2HttpMessageConverter) converter;
        ObjectMapper objectMapper = jacksonMessageConverter.getObjectMapper();
        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        break;
        }
    }
}

}
</code></pre>