-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DefaultDateTypeAdapterTest
fails on JDK 8 and 17
#2199
Comments
I have debug this test and I have figure out that the problem is the date format. Is it ok if i fix this with a ternary operator? |
I think that if we change the test so that it passes on all three tested platforms (JDK 8, 11, and 17) that would definitely be an improvement. It's still concerning that the same date string doesn't parse on all platforms, but I'm not sure how or whether we can fix that. At least making the per-platform strings explicit would be better than simply not running the test on platforms other than 11. So yes, if you want to investigate that change that would be a great contribution. Thanks in advance! |
Theoretical partFrom Java 9 the default format for the date is the Unicode Common Local Date Repository (CLDR). As written here to enable the behavior compatiple with JDK 8, you have to set the system property to: But it’s not that simple because the CLDR is available in versions, and not the same version is included with the different Java versions. That means potentially every Java version can format the date in different way. Here an example: Between the two dates there are only small differences but is enough to make the test fail because if the date pattern change also the date format should change. In fact, to pass the test (as i write above) it was enough to change the date format to pass the test ( from: Practical partProbably the first thing that we can do is say "goodbye" to the old date-time API and use the new one: Or we can keep use if/ternary operator to identify the java version and pass the correct date format but this is not a solution for the problem so i hope we don't go for it. |
If these long-format dates are parsed differently on the different platforms then the easiest thing is probably not to try to parse them. I think the short-format dates work everywhere and the ones with month names in them suffice to prove that the default locale is being used. Or alternatively, rewrite the test so that it obtains the date string to be parsed using the same kind of |
Thanks for the very detailed analysis, by the way! It's very helpful. |
…#2199 (google#2287) * Rewrite the `testParsingDatesFormattedWithSystemLocale()`, Fix google#2199 * Format the test * Format the code following Google Java Style Guide * Revert "Format the code following Google Java Style Guide" This reverts commit f5e2e16. (cherry picked from commit 6c12ded)
The text was updated successfully, but these errors were encountered: