mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8340073: Support "%z" time zone abbreviation format in TZ files
Reviewed-by: jlu, joehw, coffeys
This commit is contained in:
parent
b26645f64b
commit
418bb42b95
2 changed files with 17 additions and 9 deletions
|
@ -264,7 +264,13 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
}
|
||||
|
||||
private String toGMTFormat(String id, boolean daylight, Locale l) {
|
||||
var zr = ZoneInfoFile.getZoneInfo(id).toZoneId().getRules();
|
||||
LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
|
||||
ResourceBundle fd = lr.getJavaTimeFormatData();
|
||||
var zi = ZoneInfoFile.getZoneInfo(id);
|
||||
if (zi == null) {
|
||||
return fd.getString("timezone.gmtZeroFormat");
|
||||
}
|
||||
var zr = zi.toZoneId().getRules();
|
||||
var now = Instant.now();
|
||||
var saving = zr.getTransitions().reversed().stream()
|
||||
.dropWhile(zot -> zot.getInstant().isAfter(now))
|
||||
|
@ -276,8 +282,6 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
.orElse(0);
|
||||
int offset = (zr.getStandardOffset(now).getTotalSeconds() +
|
||||
(daylight ? saving : 0)) / 60;
|
||||
LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
|
||||
ResourceBundle fd = lr.getJavaTimeFormatData();
|
||||
|
||||
if (offset == 0) {
|
||||
return fd.getString("timezone.gmtZeroFormat");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue