本文整理汇总了Java中sun.util.calendar.ZoneInfoFile.toCustomID方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneInfoFile.toCustomID方法的具体用法?Java ZoneInfoFile.toCustomID怎么用?Java ZoneInfoFile.toCustomID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.util.calendar.ZoneInfoFile
的用法示例。
在下文中一共展示了ZoneInfoFile.toCustomID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisplayNameArray
import sun.util.calendar.ZoneInfoFile; //导入方法依赖的package包/类
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;
}
示例2: getDisplayName
import sun.util.calendar.ZoneInfoFile; //导入方法依赖的package包/类
/**
* Returns a name of this time zone suitable for presentation to the user
* in the specified locale.
* If the display name is not available for the locale,
* then this method returns a string in the
* <a href="#NormalizedCustomID">normalized custom ID format</a>.
* @param daylight if true, return the daylight savings name.
* @param style either <code>LONG</code> or <code>SHORT</code>
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale.
* @exception IllegalArgumentException style is invalid.
* @since 1.2
*/
public String getDisplayName(boolean daylight, int style, Locale locale) {
if (style != SHORT && style != LONG) {
throw new IllegalArgumentException("Illegal style: " + style);
}
String id = getID();
String[] names = getDisplayNames(id, locale);
if (names == null) {
if (id.startsWith("GMT")) {
char sign = id.charAt(3);
if (sign == '+' || sign == '-') {
return id;
}
}
int offset = getRawOffset();
if (daylight) {
offset += getDSTSavings();
}
return ZoneInfoFile.toCustomID(offset);
}
int index = daylight ? 3 : 1;
if (style == SHORT) {
index++;
}
return names[index];
}
示例3: getDisplayName
import sun.util.calendar.ZoneInfoFile; //导入方法依赖的package包/类
/**
* Returns a name in the specified {@code style} of this {@code TimeZone}
* suitable for presentation to the user in the specified {@code
* locale}. If the specified {@code daylight} is {@code true}, a Daylight
* Saving Time name is returned (even if this {@code TimeZone} doesn't
* observe Daylight Saving Time). Otherwise, a Standard Time name is
* returned.
*
* <p>When looking up a time zone name, the {@linkplain
* ResourceBundle.Control#getCandidateLocales(String,Locale) default
* <code>Locale</code> search path of <code>ResourceBundle</code>} derived
* from the specified {@code locale} is used. (No {@linkplain
* ResourceBundle.Control#getFallbackLocale(String,Locale) fallback
* <code>Locale</code>} search is performed.) If a time zone name in any
* {@code Locale} of the search path, including {@link Locale#ROOT}, is
* found, the name is returned. Otherwise, a string in the
* <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
*
* @param daylight {@code true} specifying a Daylight Saving Time name, or
* {@code false} specifying a Standard Time name
* @param style either {@link #LONG} or {@link #SHORT}
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale.
* @exception IllegalArgumentException if {@code style} is invalid.
* @exception NullPointerException if {@code locale} is {@code null}.
* @since 1.2
* @see java.text.DateFormatSymbols#getZoneStrings()
*/
public String getDisplayName(boolean daylight, int style, Locale locale) {
if (style != SHORT && style != LONG) {
throw new IllegalArgumentException("Illegal style: " + style);
}
String id = getID();
String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale);
if (name != null) {
return name;
}
if (id.startsWith("GMT") && id.length() > 3) {
char sign = id.charAt(3);
if (sign == '+' || sign == '-') {
return id;
}
}
int offset = getRawOffset();
if (daylight) {
offset += getDSTSavings();
}
return ZoneInfoFile.toCustomID(offset);
}
示例4: getDisplayName
import sun.util.calendar.ZoneInfoFile; //导入方法依赖的package包/类
/**
* Returns a name in the specified {@code style} of this {@code TimeZone}
* suitable for presentation to the user in the specified {@code
* locale}. If the specified {@code daylight} is {@code true}, a Daylight
* Saving Time name is returned (even if this {@code TimeZone} doesn't
* observe Daylight Saving Time). Otherwise, a Standard Time name is
* returned.
*
* <p>When looking up a time zone name, the {@linkplain
* ResourceBundle.Control#getCandidateLocales(String,Locale) default
* <code>Locale</code> search path of <code>ResourceBundle</code>} derived
* from the specified {@code locale} is used. (No {@linkplain
* ResourceBundle.Control#getFallbackLocale(String,Locale) fallback
* <code>Locale</code>} search is performed.) If a time zone name in any
* {@code Locale} of the search path, including {@link Locale#ROOT}, is
* found, the name is returned. Otherwise, a string in the
* <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
*
* @param daylight {@code true} specifying a Daylight Saving Time name, or
* {@code false} specifying a Standard Time name
* @param style either {@link #LONG} or {@link #SHORT}
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale.
* @exception IllegalArgumentException if {@code style} is invalid.
* @exception NullPointerException if {@code locale} is {@code null}.
* @since 1.2
* @see java.text.DateFormatSymbols#getZoneStrings()
*/
public String getDisplayName(boolean daylight, int style, Locale locale) {
if (style != SHORT && style != LONG) {
throw new IllegalArgumentException("Illegal style: " + style);
}
String id = getID();
String[] names = getDisplayNames(id, locale);
if (names == null) {
if (id.startsWith("GMT")) {
char sign = id.charAt(3);
if (sign == '+' || sign == '-') {
return id;
}
}
int offset = getRawOffset();
if (daylight) {
offset += getDSTSavings();
}
return ZoneInfoFile.toCustomID(offset);
}
int index = daylight ? 3 : 1;
if (style == SHORT) {
index++;
}
return names[index];
}