title: ObjectMapper changes Date to String
body: <p>I am trying to use Jackson ObjectMappper to convert my Java POJO to Map. But, on converting, the Date changes to String. </p>
  
  <p>This is my POJO: </p>
  
  <pre><code>public class Sample {
  
      @Id
      private String id;
      private Date date;
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public Date getDate() {
          return date;
      }
  
      public void setDate(Date date) {
          this.date = date;
      }
  }
  </code></pre>
  
  <p>Here is my code: </p>
  
  <pre><code>@Test
  public void testGenMap() {
      Sample sample = new Sample();
      sample.setId("a");
      sample.setDate(new Date());
      Map&lt;String, Object&gt; map = generateMap(sample);
      System.out.println(map.get("date") instanceof Date); //false
  }
  
  private Map&lt;String, Object&gt; generateMap(Sample sample) {
  Map&lt;String, Object&gt; map = CommonsContextUtil.getBean(ObjectMapper.class).convertValue(sample,Map.class);
          map.values().removeIf(Objects::isNull);
          return map;
      }
  </code></pre>
  
  <p>I know this already has a possible answer <a href="https://stackoverflow.com/questions/26071530/jackson-convert-object-to-map-preserving-date-type">here</a>. But my ObjectMapper is already configured in the same way and still it is not working. </p>
  
  <p>Here is the ObjectMapper Bean: </p>
  
  <pre><code>@Bean
  public ObjectMapper objectMapper() {
      ObjectMapper mapper = new ObjectMapper();
      mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
      mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);
      mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
      return mapper;
  }
  </code></pre>