question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date format is not respected when serializing map with Date as key

See original GitHub issue
What steps will reproduce the problem?
1. Crete Map<Date,Object> and populate with random data
2. Create Gson using GsonBuilder and setDateFormat("any format")
3. Serialize map to json.

What is the expected output? What do you see instead?
I expect keys to be serialized using date format, but I see that keys are 
converted to strings using Date.toString() which uses generic "EEE MMM dd 
HH:mm:ss z yyyy" format

What version of the product are you using? On what operating system?
2.2.4 from Maven,Ubuntu Linux

Original issue reported on code.google.com by mbrzezi...@gmail.com on 28 Oct 2013 at 5:42

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
nardrascommented, Feb 22, 2017

same issue here - already tried implementing cusom deserializers, but no luck so far. Any chance this gets resolved?

1reaction
jpberniuscommented, Feb 7, 2017

Any Update or Workaround on this issue? Still experiencing this problem in 2.8.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date format Mapping to JSON Jackson - java - Stack Overflow
Using this implementation the execution of the serialization and deserialization process consecutively results the origin value. Only using the ...
Read more >
The optimal way to include dates in JSON - Dev Genius
JSON format does not have a special type for dates. So dates have to be represented in JSONs as numbers of milliseconds or...
Read more >
Jackson Date - Baeldung
In this tutorial, we'll serialize dates with Jackson. We'll start by serializing a simple java.util.Date, then Joda-Time, and finally, the Java ...
Read more >
JavaScript JSON Date Parsing and real Dates - Rick Strahl
JavaScript doesn't have a date literal, and for this reason JSON serializes dates as strings rather than real JavaScript dates.
Read more >
The Serializer Component (Symfony Docs)
The same way, Normalizers will deal with turning specific objects into arrays and vice versa. Serialization is a complex topic. This component may...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found