title: How to make JsonGenerator pretty-print Date and DateTime values?
body: <p>I'm using this method to convert any object to a json string:</p>
  
  <pre><code>private String objectToJson(Object object) throws IOException {
          // write JSON
          StringWriter writer = new StringWriter();
          ObjectMapper mapper = new ObjectMapper();
          final JsonGenerator jsonGenerator = mapper.getJsonFactory().createJsonGenerator(writer);
          jsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter());
  
          mapper.writeValue(jsonGenerator, object);
          return writer.toString();
      }
  </code></pre>
  
  <p>When the object being printed contains fields that are java.util.Date or jodatime's DateTime, the printed value is the number of milliseconds since the epoch. I would like, instead, to pretty-print them in a standard "HH:MM:SS" notation. How should I go about doing this?</p>