Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java9 DateFormat changes #1210

Closed
amogilev opened this issue Dec 20, 2017 · 0 comments
Closed

Java9 DateFormat changes #1210

amogilev opened this issue Dec 20, 2017 · 0 comments

Comments

@amogilev
Copy link
Contributor

amogilev commented Dec 20, 2017

The default formats used in DateFormat has changes in Java 9. For example:

  • Java8 (and below): "Jan 1, 1970 12:00:00 AM"
  • Java9: "Jan 1, 1970, 12:00:00 AM"
  • Java8 (and below): "Thursday, January 1, 1970 12:00:00 AM UTC"
  • Java9: "Thursday, January 1, 1970 at 12:00:00 AM Coordinated Universal Time"

As a result, a number of Gson unit tests currently fail when run on Java 9. Additionally, this causes some sort of a backward incompatibility: a date written by Gson in Java 8 cannot be parsed back in Java 9.

In order to fix it, I suggest the following changes:

  • provide a way for Gson to read default "old" formats. As Gson by default uses only US date formats, it is possible;
  • change "write" unit tests so that they check the results depending on the current Java version. If run on Java 9 or later, expect the new formats to be used; otherwise, expect the "old" results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant