src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 28,37 ****
--- 28,38 ----
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.spi.TimeZoneNameProvider;
+ import sun.util.calendar.ZoneInfoFile;
/**
* Concrete implementation of the
* {@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider} class
* for the JRE LocaleProviderAdapter.
*** 40,49 ****
--- 41,51 ----
* @author Masayoshi Okutsu
*/
public class TimeZoneNameProviderImpl extends TimeZoneNameProvider {
private final LocaleProviderAdapter.Type type;
private final Set<String> langtags;
+ private static final String CLDR_NO_INHERITANCE_MARKER = "\u2205\u2205\u2205";
TimeZoneNameProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
this.type = type;
this.langtags = langtags;
}
*** 60,70 ****
return LocaleProviderAdapter.toLocaleArray(langtags);
}
@Override
public boolean isSupportedLocale(Locale locale) {
! return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags);
}
/**
* Returns a name for the given time zone ID that's suitable for
* presentation to the user in the specified locale. The given time
--- 62,72 ----
return LocaleProviderAdapter.toLocaleArray(langtags);
}
@Override
public boolean isSupportedLocale(Locale locale) {
! return LocaleProviderAdapter.forType(type).isSupportedProviderLocale(locale, langtags);
}
/**
* Returns a name for the given time zone ID that's suitable for
* presentation to the user in the specified locale. The given time
*** 119,129 ****
}
private String[] getDisplayNameArray(String id, Locale locale) {
Objects.requireNonNull(id);
Objects.requireNonNull(locale);
! return LocaleProviderAdapter.forType(type).getLocaleResources(locale).getTimeZoneNames(id);
}
/**
* Returns a String[][] as the DateFormatSymbols.getZoneStrings() value for
* the given locale. This method is package private.
--- 121,152 ----
}
private String[] getDisplayNameArray(String id, Locale locale) {
Objects.requireNonNull(id);
Objects.requireNonNull(locale);
!
! String[] ret =
! LocaleProviderAdapter.forType(type).getLocaleResources(locale).getTimeZoneNames(id);
!
! if (Objects.nonNull(ret) && type == LocaleProviderAdapter.Type.CLDR) {
! // check for CLDR's "no inheritance marker"
! for (int index = 0; index < ret.length; index++) {
! TimeZone tz = null;
! if (CLDR_NO_INHERITANCE_MARKER.equals(ret[index])) {
! if (Objects.isNull(tz)) {
! tz = TimeZone.getTimeZone(id);
! }
! int offset = tz.getRawOffset();
! if (index == 3 || index == 4) { // daylight
! offset += tz.getDSTSavings();
! }
! ret[index] = ZoneInfoFile.toCustomID(offset);
! }
! }
! }
!
! return ret;
}
/**
* Returns a String[][] as the DateFormatSymbols.getZoneStrings() value for
* the given locale. This method is package private.