title: Date and Timestamp serialization by Jackson ObjectMapper
body: <p>Jackson <code>ObjectMapper</code> is serializing both <code>Date</code> and <code>Timestamp</code> as <code>Long</code> in <strong>2.9.x</strong> version whereas Date is serialized as <code>Formatted String</code> in <strong>2.6.x</strong> and <code>Timestamp</code> as <code>Long</code> in **2.6.x* version by default. </p>
  
  <p>Example:</p>
  
  <pre><code>case class Test(date: java.sql.Date,  tmp: java.sql.Timestamp)
  val test = Test(new java.sql.Date(1588892400000L), new Timestamp(1588892400000L))
  writeValueAsString(test)
  </code></pre>
  
  <pre><code>{"date":"2020-05-08","tmp":1588892400000}//Version 2.6.x 
  {"date":1588892400000,"tmp":1588892400000}//Version 2.9.x
  </code></pre>
  
  <blockquote>
    <p>But I want to maintain the behavior of <strong>2.6.x</strong> version in <strong>2.9.x</strong> version.</p>
  </blockquote>
  
  <p>I tried <code>disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)</code> but then it is converting both <code>Date</code> &amp; <code>TimeStamp</code> to <code>Formatted String</code> (as below).</p>
  
  <pre><code>{"date":"2020-05-08","tmp":"2020-05-07T23:00:00.000+0000"}
  </code></pre>
  
  <p>If I set DateFormatter**, then it converts both in the same format.</p>
  
  <pre><code>setDateFormat(new SimpleDateFormat("yyyy-MM-dd"))`
  {"date":"2020-05-08","tmp":"2020-05-08"}
  </code></pre>
  
  <p>**I just treid it but I don't want to set DateFormatter (even if it works) because it will be used for de-serialization too where the input date format is different.</p>
  
  <p>Is there a way to achieve this?</p>