当前位置: 首页>>代码示例>>Java>>正文


Java ZoneInfoFile类代码示例

本文整理汇总了Java中sun.util.calendar.ZoneInfoFile的典型用法代码示例。如果您正苦于以下问题:Java ZoneInfoFile类的具体用法?Java ZoneInfoFile怎么用?Java ZoneInfoFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ZoneInfoFile类属于sun.util.calendar包,在下文中一共展示了ZoneInfoFile类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toZoneId0

import sun.util.calendar.ZoneInfoFile; //导入依赖的package包/类
private ZoneId toZoneId0() {
    String id = getID();
    TimeZone defaultZone = defaultTimeZone;
    // are we not defaultTimeZone but our id is equal to default's?
    if (defaultZone != this &&
        defaultZone != null && id.equals(defaultZone.getID())) {
        // delegate to default TZ which is effectively immutable
        return defaultZone.toZoneId();
    }
    // derive it ourselves
    if (ZoneInfoFile.useOldMapping() && id.length() == 3) {
        if ("EST".equals(id))
            return ZoneId.of("America/New_York");
        if ("MST".equals(id))
            return ZoneId.of("America/Denver");
        if ("HST".equals(id))
            return ZoneId.of("America/Honolulu");
    }
    return ZoneId.of(id, ZoneId.SHORT_IDS);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:TimeZone.java

示例2: 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TimeZoneNameProviderImpl.java

示例3: toZoneId

import sun.util.calendar.ZoneInfoFile; //导入依赖的package包/类
/**
 * Converts this {@code TimeZone} object to a {@code ZoneId}.
 *
 * @return a {@code ZoneId} representing the same time zone as this
 *         {@code TimeZone}
 * @since 1.8
 */
public ZoneId toZoneId() {
    String id = getID();
    if (ZoneInfoFile.useOldMapping() && id.length() == 3) {
        if ("EST".equals(id))
            return ZoneId.of("America/New_York");
        if ("MST".equals(id))
            return ZoneId.of("America/Denver");
        if ("HST".equals(id))
            return ZoneId.of("America/Honolulu");
    }
    return ZoneId.of(id, ZoneId.SHORT_IDS);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:TimeZone.java

示例4: 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];
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:41,代码来源:TimeZone.java

示例5: 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:TimeZone.java

示例6: 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];
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:56,代码来源:TimeZone.java


注:本文中的sun.util.calendar.ZoneInfoFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。