title: Jackson 1.9 configuration for spring 3.1 (to globally set dateformat)
body: <p>I successfully use Spring 3.1 mvc to produce rest webservices using json as http message. Until now I was setting on every field in my beans the notation to use a custom serializer/deserializer and ask jackson to format my date in a specific format. Now I would like to delete this notation syntax, and set a global dateformat. This is how i made it</p>
  
  <p>this is my servlet configuration</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
  xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"&gt;
  
  &lt;context:component-scan base-package="com.test.endpoints" /&gt;
  
  &lt;mvc:annotation-driven&gt;
      &lt;mvc:message-converters register-defaults="false"&gt;
          &lt;bean
              class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&gt;
              &lt;property name="objectMapper"&gt;
                  &lt;bean class="com.test.CustomObjectMapper" /&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/mvc:message-converters&gt;
  &lt;/mvc:annotation-driven&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>this is the class CustomObjectMapper</p>
  
  <pre><code>package com.test;
  
  import java.text.SimpleDateFormat;
  import org.codehaus.jackson.map.ObjectMapper;
  import org.codehaus.jackson.map.SerializationConfig.Feature;
  
  public class CustomObjectMapper extends ObjectMapper {
  
      public CustomObjectMapper() {
          super();
          configure(Feature.WRITE_DATES_AS_TIMESTAMPS, false);
          setDateFormat(new SimpleDateFormat(
                  "EEE MMM dd yyyy HH:mm:ss 'GMT'ZZZ (z)"));
      }
  }
  </code></pre>