google / gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Apache License 2.0
23.37k stars 4.28k forks source link

java.util.date Java 11 vs Java 8 different serialization #1719

Open col-panic opened 4 years ago

col-panic commented 4 years ago

I don't know what to make of this, whether its a bug or not - but I think its worth mentioning. If you serialize a java.util.Date object, this is what you get with gson 2.8.0

Java 8 {"creationDate":"Jun 10, 2020 11:13:39 AM"} Java 11 {"creationDate":"Jun 10, 2020, 11:14:17 AM"}

see the extra , after the year? Java 11 serialized java.util.Date is not deserializable in Java 8.

Marcono1234 commented 4 years ago

Java 11 serialized java.util.Date is not deserializable in Java 11.

You probably meant "Java 8", right? The date format change comes from the JDK, see #1210. It appears #1682 already describes the incompability issues you are describing here.

creeper0167 commented 1 year ago

Is this still open?...Can I work on this?

MaicolAntali commented 1 year ago

Probably it's related to the CLDR version included in the JDK. Here you can find some information: Link.

Jarvan-Song commented 1 year ago

has been fixed ?

Marcono1234 commented 1 year ago

@Jarvan-Song, not as far as I know. In general it might be good to avoid the default Gson date format though and choose a stable and machine readable one, see also this Stack Overflow question.

Jarvan-Song commented 1 year ago

@Jarvan-Song, not as far as I know. In general it might be good to avoid the default Gson date format though and choose a stable and machine readable one, see also this Stack Overflow question.

thanks