title: How to (de)serialize DateTime objects as ISO8601 using Jackson 2.0?
body: <p>I'd like to know whether it is possible to [de]serialize a Joda <code>DateTime</code> object into a ISO8601 <code>String</code> using Jackson without creating a custom <code>JsonSerializer&lt;DateTime&gt;</code>.</p>
  
  <p>Surely this is a common enough function that is built into the library somewhere? The closest I could find is a <code>SerializationFeature.WRITE_DATES_AS_TIMESTAMPS</code>, but this seems to only apply to <code>Date</code> objects.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I found <a href="http://fasterxml.github.com/jackson-databind/javadoc/2.0.0/com/fasterxml/jackson/databind/util/ISO8601DateFormat.html" rel="nofollow">this class</a>: <code>ISO8601DateFormat</code>, but when I try the following code I don't get an ISO8601 string:</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  mapper.setDateFormat(new ISO8601DateFormat());
  mapper.writer().writeValueAsString(DateTime.now());
  </code></pre>
  
  <p>Looks like Jackson doesn't treat Date and DateTime objects equally.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I ended up writing a custom serializer for ISO8601 DateTime strings.</p>