本文整理汇总了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;
}
示例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;
}
示例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;
}