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


Java TimeZoneNameUtility类代码示例

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


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

示例1: getZoneStringsImpl

import sun.util.locale.provider.TimeZoneNameUtility; //导入依赖的package包/类
private String[][] getZoneStringsImpl(boolean needsCopy) {
    if (zoneStrings == null) {
        zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
    }

    if (!needsCopy) {
        return zoneStrings;
    }

    int len = zoneStrings.length;
    String[][] aCopy = new String[len][];
    for (int i = 0; i < len; i++) {
        aCopy[i] = Arrays.copyOf(zoneStrings[i], zoneStrings[i].length);
    }
    return aCopy;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:DateFormatSymbols.java

示例2: getDisplayName

import sun.util.locale.provider.TimeZoneNameUtility; //导入依赖的package包/类
private String getDisplayName(String id, int type, Locale locale) {
    if (textStyle == TextStyle.NARROW) {
        return null;
    }
    String[] names;
    SoftReference<Map<Locale, String[]>> ref = cache.get(id);
    Map<Locale, String[]> perLocale = null;
    if (ref == null || (perLocale = ref.get()) == null ||
        (names = perLocale.get(locale)) == null) {
        names = TimeZoneNameUtility.retrieveDisplayNames(id, locale);
        if (names == null) {
            return null;
        }
        names = Arrays.copyOfRange(names, 0, 7);
        names[5] =
            TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale);
        if (names[5] == null) {
            names[5] = names[0]; // use the id
        }
        names[6] =
            TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale);
        if (names[6] == null) {
            names[6] = names[0];
        }
        if (perLocale == null) {
            perLocale = new ConcurrentHashMap<>();
        }
        perLocale.put(locale, names);
        cache.put(id, new SoftReference<>(perLocale));
    }
    switch (type) {
    case STD:
        return names[textStyle.zoneNameStyleIndex() + 1];
    case DST:
        return names[textStyle.zoneNameStyleIndex() + 3];
    }
    return names[textStyle.zoneNameStyleIndex() + 5];
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:DateTimeFormatterBuilder.java

示例3: test

import sun.util.locale.provider.TimeZoneNameUtility; //导入依赖的package包/类
private static void test(String tzid, int style, Locale locale, String expected) {
    // No public API to get generic time zone names (JDK 8)
    String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale);
    if (!expected.equals(got)) {
        System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n",
                          tzid, locale, style, got, expected);
        errors++;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:GenericTimeZoneNamesTest.java

示例4: testGenericTZName

import sun.util.locale.provider.TimeZoneNameUtility; //导入依赖的package包/类
public static void testGenericTZName( Locale locale, String timezoneName,
                                      int nameType, String expectedName ) throws RuntimeException {
    if (testGeneric) {
        String genericName = TimeZoneNameUtility.retrieveGenericDisplayName(timezoneName, nameType, locale);
        //Check for equality
        if (!genericName.equals(expectedName))
            throw new RuntimeException( "Time zone ("+timezoneName+") name is incorrect for locale \""+locale.getDisplayName()
                                        +"\" nameType: Generic"+"("+nameType+") Should be: " +expectedName+" Observed: "+genericName);
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:11,代码来源:TimeZoneNamesTest.java

示例5: getDisplayName

import sun.util.locale.provider.TimeZoneNameUtility; //导入依赖的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: getDisplayNames

import sun.util.locale.provider.TimeZoneNameUtility; //导入依赖的package包/类
private static String[] getDisplayNames(String id, Locale locale) {
    return TimeZoneNameUtility.retrieveDisplayNames(id, locale);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:TimeZone.java


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