title: Deserialize MongoDB date fields to Java POJO Using Jackson
body: <p>Using Spring Boot 1.4.4.RELEASE, have saved a <code>RequestBody</code> to MongoDB as below:</p>
  
  <pre><code>{
      "startTime" : NumberLong("1483542955570"),
      "startDate" : ISODate("2017-01-04T15:15:55.570Z"),
      "endTime" : NumberLong("1483542955570"),
      "endDate" : ISODate("2017-01-04T15:15:55.570Z")
  }
  </code></pre>
  
  <p>While mapping this back to a Java POJO, I am trying the below code.</p>
  
  <pre><code>public &lt;T&gt; T getPOJOFromMongoDocument(Document resourceDocument, Class&lt;T&gt; clazz) {
          String serialize = JSON.serialize(resourceDocument);
          return objectMapper.readValue(serialize,
                                        clazz);
  }
  </code></pre>
  
  <p>serialize has the date fields returned as following</p>
  
  <pre><code>"startDate" : { "$date" : "2017-01-04T15:15:55.570Z"}
  </code></pre>
  
  <p>Due to <code>$date</code>, Jackson <code>ObjectMapper</code> returns the below exception during parsing:</p>
  
  <pre><code>java.lang.RuntimeException: Error parsing mongoDoc to Pojo : errorMessage : {Can not deserialize instance of java.util.Date out of START_OBJECT token at [Source: {
  "startTime": 1483542955570,
  "startDate": {
      "$date": "2017-01-04T15:15:55.570Z"
  },
  "endTime": 1483542955570,
  "endDate": {
      "$date": "2017-01-04T15:15:55.570Z"
  }}; line: 1, column: 381] (through reference chain: com.gofynd.engine.mongo.models.RuleWithDataVO["validity"]-&gt;com.gofynd.engine.mongo.models.ValidityVO["startDate"])}
  </code></pre>
  
  <p>Is there way to solve this without using an ODM?</p>