Stop using using legacy locale data for Date/Time formatting tests

Commit 84714fbae9 introduced usage of the
-Djava.locale.providers=COMPAT command-line argument for javac in order
to allow our JDK 20 builds to pass by using legacy locale data.

That was done to ensure that Date/Time formats using AM/PM produced a
standard space (" ") before the "AM" or "PM" instead of a narrow
non-breaking space (NNBSP "\u202F"), which was introduced in Java 20
due to adoption of Unicode Common Locale Data Repository (CLDR-14032).

This commit removes usage of the -Djava.locale.providers=COMPAT
command-line argument and updates all affected tests to:

- Use an NNBSP before "AM" or "PM" in input text when running on Java 20
  or higher.

- Leniently match against any Unicode space character in formatted
  values containing "AM" or "PM".

See https://jdk.java.net/20/release-notes#JDK-8284840
See https://unicode-org.atlassian.net/browse/CLDR-14032
See gh-30185
Closes gh-33144
This commit is contained in:
Sam Brannen
2024-07-04 17:02:46 +02:00
parent 51641ece72
commit 89338c91a9
4 changed files with 56 additions and 23 deletions

View File

@@ -128,9 +128,10 @@ class GsonFactoryBeanTests {
cal.set(Calendar.DATE, 1);
Date date = cal.getTime();
bean.setDate(date);
// \p{Zs} matches any Unicode space character
assertThat(gson.toJson(bean))
.startsWith("{\"date\":\"Jan 1, 2014")
.endsWith("12:00:00 AM\"}");
.matches(".+?12:00:00\\p{Zs}AM\"}");
}
@Test