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


Java ULocale.equals方法代码示例

本文整理汇总了Java中com.ibm.icu.util.ULocale.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ULocale.equals方法的具体用法?Java ULocale.equals怎么用?Java ULocale.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.icu.util.ULocale的用法示例。


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

示例1: getRangeFormat

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Return a formatter (compiled SimpleFormatter pattern) for a range, such as "{0}–{1}".
 * @param forLocale locale to get the format for
 * @param width the format width
 * @return range formatter, such as "{0}–{1}"
 * @internal
 * @deprecated This API is ICU internal only.
 */
@Deprecated
public static String getRangeFormat(ULocale forLocale, FormatWidth width) {
    // TODO fix Hack for French
    if (forLocale.getLanguage().equals("fr")) {
        return getRangeFormat(ULocale.ROOT, width);
    }
    String result = localeIdToRangeFormat.get(forLocale);
    if (result == null) {
        ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.
                getBundleInstance(ICUData.ICU_BASE_NAME, forLocale);
        ULocale realLocale = rb.getULocale();
        if (!forLocale.equals(realLocale)) { // if the child would inherit, then add a cache entry for it.
            result = localeIdToRangeFormat.get(forLocale);
            if (result != null) {
                localeIdToRangeFormat.put(forLocale, result);
                return result;
            }
        }
        // At this point, both the forLocale and the realLocale don't have an item
        // So we have to make one.
        NumberingSystem ns = NumberingSystem.getInstance(forLocale);

        String resultString = null;
        try {
            resultString = rb.getStringWithFallback("NumberElements/" + ns.getName() + "/miscPatterns/range");
        } catch ( MissingResourceException ex ) {
            resultString = rb.getStringWithFallback("NumberElements/latn/patterns/range");
        }
        result = SimpleFormatterImpl.compileToStringMinMaxArguments(
                resultString, new StringBuilder(), 2, 2);
        localeIdToRangeFormat.put(forLocale, result);
        if (!forLocale.equals(realLocale)) {
            localeIdToRangeFormat.put(realLocale, result);
        }
    }
    return result;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:46,代码来源:MeasureFormat.java

示例2: getDefaultPattern

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private static synchronized String getDefaultPattern() {
    ULocale defaultLocale = ULocale.getDefault(Category.FORMAT);
    if (!defaultLocale.equals(cachedDefaultLocale)) {
        cachedDefaultLocale = defaultLocale;
        Calendar cal = Calendar.getInstance(cachedDefaultLocale);

        try {
            // Load the calendar data directly.
            ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(
                    ICUData.ICU_BASE_NAME, cachedDefaultLocale);
            String resourcePath = "calendar/" + cal.getType() + "/DateTimePatterns";
            ICUResourceBundle patternsRb= rb.findWithFallback(resourcePath);

            if (patternsRb == null) {
                patternsRb = rb.findWithFallback("calendar/gregorian/DateTimePatterns");
            }
            if (patternsRb == null || patternsRb.getSize() < 9) {
                cachedDefaultPattern = FALLBACKPATTERN;
            } else {
                int defaultIndex = 8;
                if (patternsRb.getSize() >= 13) {
                    defaultIndex += (SHORT + 1);
                }
                String basePattern = patternsRb.getString(defaultIndex);

                cachedDefaultPattern = SimpleFormatterImpl.formatRawPattern(
                        basePattern, 2, 2,
                        patternsRb.getString(SHORT), patternsRb.getString(SHORT + 4));
            }
        } catch (MissingResourceException e) {
            cachedDefaultPattern = FALLBACKPATTERN;
        }
    }
    return cachedDefaultPattern;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:36,代码来源:SimpleDateFormat.java

示例3: get

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
public LocaleDisplayNames get(ULocale locale, DialectHandling dialectHandling) {
    if (!(dialectHandling == this.dialectHandling && DisplayContext.CAPITALIZATION_NONE == this.capitalization &&
            DisplayContext.LENGTH_FULL == this.nameLength && DisplayContext.SUBSTITUTE == this.substituteHandling &&
            locale.equals(this.locale))) {
        this.locale = locale;
        this.dialectHandling = dialectHandling;
        this.capitalization = DisplayContext.CAPITALIZATION_NONE;
        this.nameLength = DisplayContext.LENGTH_FULL;
        this.substituteHandling = DisplayContext.SUBSTITUTE;
        this.cache = new LocaleDisplayNamesImpl(locale, dialectHandling);
    }
    return cache;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:14,代码来源:LocaleDisplayNamesImpl.java


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