title: How to serialize Dates into HashMap?
body: <p>I have a use case where I get the object as  a json string and consecutively needs to transform it into a HashMap. My code is as follows:</p>
  
  <pre><code>public Map&lt;String, Object&gt; toMap(String jsonString) {
    Gson gson = new Gson();
  
    Type type = new TypeToken&lt;Map&lt;String, Object&gt;&gt;() {
    }.getType();
    Map&lt;String, Object&gt; mapped = gson.fromJson(jsonString, type);
    return mapped;
  }
  </code></pre>
  
  <p>The date value I get from jsonString is <code>"date": "2018-07-29T23:52:35.814Z"</code> but upon serialization into HashMap, the "date" value is a String and not a Date object. Is there a way around it? Even solutions where Gson is not used is welcome</p>
  
  <p>Sample jsonString is as follows:</p>
  
  <pre><code>{
      "id": "1351",
      "date": "2018-07-30T00:32:31.564Z",
      "university": "US",
      "typeofwork": "Report",
      "title": "Thesis title",
      "subject": "Masters",
      "noofwords": "123"
  }
  </code></pre>
  
  <p>To clarify, I am not getting any errors with the serialization/deserialization per se. I just want the <code>date</code> value to be of type <code>java.util.Date</code> such that a validation of <code>if(map.get("date") instanceOf java.util.Date)</code> will return true </p>