mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8210490: TimeZone.getDisplayName given Locale.US doesn't always honor the Locale
Specified locale for formatting.. Reviewed-by: naoto
This commit is contained in:
parent
6b8fd447cc
commit
36873c3c7b
2 changed files with 18 additions and 7 deletions
|
@ -281,7 +281,7 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
||||||
.replaceFirst("H+", (isShort ? "\\%1\\$d" : "\\%1\\$02d"))
|
.replaceFirst("H+", (isShort ? "\\%1\\$d" : "\\%1\\$02d"))
|
||||||
.replaceFirst("m+", "\\%2\\$02d");
|
.replaceFirst("m+", "\\%2\\$02d");
|
||||||
return MessageFormat.format(gmtFormat,
|
return MessageFormat.format(gmtFormat,
|
||||||
String.format(hourFormat, offset / 60, offset % 60));
|
String.format(l, hourFormat, offset / 60, offset % 60));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8005471 8008577 8129881 8130845 8136518 8181157
|
* @bug 8005471 8008577 8129881 8130845 8136518 8181157 8210490
|
||||||
* @modules jdk.localedata
|
* @modules jdk.localedata
|
||||||
* @run main/othervm -Djava.locale.providers=CLDR CLDRDisplayNamesTest
|
* @run main/othervm -Djava.locale.providers=CLDR CLDRDisplayNamesTest
|
||||||
* @summary Make sure that localized time zone names of CLDR are used
|
* @summary Make sure that localized time zone names of CLDR are used
|
||||||
|
@ -117,6 +117,17 @@ public class CLDRDisplayNamesTest {
|
||||||
Locale.setDefault(originalLocale);
|
Locale.setDefault(originalLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for 8210490
|
||||||
|
// Check that TimeZone.getDisplayName should honor passed locale parameter,
|
||||||
|
// even if default locale is set to some other locale.
|
||||||
|
Locale.setDefault(Locale.forLanguageTag("ar-PK"));
|
||||||
|
TimeZone zi = TimeZone.getTimeZone("Etc/GMT-5");
|
||||||
|
String displayName = zi.getDisplayName(false, TimeZone.SHORT, Locale.US);
|
||||||
|
Locale.setDefault(originalLocale);
|
||||||
|
if (!displayName.equals("GMT+05:00")) {
|
||||||
|
System.err.printf("Wrong display name for timezone Etc/GMT-5 : expected GMT+05:00, Actual " + displayName);
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
if (errors > 0) {
|
if (errors > 0) {
|
||||||
throw new RuntimeException("test failed");
|
throw new RuntimeException("test failed");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue