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


Java ULocale.getDefault方法代码示例

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


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

示例1: setup

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private void setup() {
    if (locale == null) {
        if (format != null) {
            locale = format.getLocale(null);
        } else {
            locale = ULocale.getDefault(Category.FORMAT);
        }
        // Needed for getLocale(ULocale.VALID_LOCALE)
        setLocale(locale, locale);
    }
    if (format == null) {
        format = NumberFormat.getNumberInstance(locale);
    }
    pluralRules = PluralRules.forLocale(locale);
    timeUnitToCountToPatterns = new HashMap<TimeUnit, Map<String, Object[]>>();
    Set<String> pluralKeywords = pluralRules.getKeywords();
    setup("units/duration", timeUnitToCountToPatterns, FULL_NAME, pluralKeywords);
    setup("unitsShort/duration", timeUnitToCountToPatterns, ABBREVIATED_NAME, pluralKeywords);
    isReady = true;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:21,代码来源:TimeUnitFormat.java

示例2: DecimalFormat

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Creates a DecimalFormat using the default pattern and symbols for the default
 * <code>FORMAT</code> locale. This is a convenient way to obtain a DecimalFormat when
 * internationalization is not the main concern.
 *
 * <p>To obtain standard formats for a given locale, use the factory methods on
 * NumberFormat such as getNumberInstance.  These factories will return the most
 * appropriate sub-class of NumberFormat for a given locale.
 *
 * @see NumberFormat#getInstance
 * @see NumberFormat#getNumberInstance
 * @see NumberFormat#getCurrencyInstance
 * @see NumberFormat#getPercentInstance
 * @see Category#FORMAT
 * @stable ICU 2.0
 */
public DecimalFormat() {
    ULocale def = ULocale.getDefault(Category.FORMAT);
    String pattern = getPattern(def, 0);
    // Always applyPattern after the symbols are set
    this.symbols = new DecimalFormatSymbols(def);
    setCurrency(Currency.getInstance(def));
    applyPatternWithoutExpandAffix(pattern, false);
    if (currencySignCount == CURRENCY_SIGN_COUNT_IN_PLURAL_FORMAT) {
        currencyPluralInfo = new CurrencyPluralInfo(def);
        // the exact pattern is not known until the plural count is known.
        // so, no need to expand affix now.
    } else {
        expandAffixAdjustWidth(null);
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:32,代码来源:DecimalFormat.java

示例3: toUpper

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
public static String toUpper(ULocale locale, String str) {
    if (locale == null) {
        locale = ULocale.getDefault();
    }
    int[] locCache = new int[] { UCaseProps.getCaseLocale(locale, null) };
    if (locCache[0] == UCaseProps.LOC_GREEK) {
        return GreekUpper.toUpper(str, locCache);
    }

    StringContextIterator iter = new StringContextIterator(str);
    StringBuilder result = new StringBuilder(str.length());
    int c;
    while((c=iter.nextCaseMapCP())>=0) {
        c = UCaseProps.INSTANCE.toFullUpper(c, iter, result, locale, locCache);
        appendResult(c, result);
    }
    return result.toString();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:19,代码来源:CaseMap.java

示例4: getEffectiveCurrency

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Returns the currency in effect for this formatter.  Subclasses
 * should override this method as needed.  Unlike getCurrency(),
 * this method should never return null.
 * @return a non-null Currency
 * @internal
 * @deprecated This API is ICU internal only.
 */
@Deprecated
protected Currency getEffectiveCurrency() {
    Currency c = getCurrency();
    if (c == null) {
        ULocale uloc = getLocale(ULocale.VALID_LOCALE);
        if (uloc == null) {
            uloc = ULocale.getDefault(Category.FORMAT);
        }
        c = Currency.getInstance(uloc);
    }
    return c;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:21,代码来源:NumberFormat.java

示例5: initialize

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private void initialize() {
    if (locale == null) {
        locale = ULocale.getDefault(Category.FORMAT);
    }
    if (formatData == null) {
        formatData = new DateFormatSymbols(locale);
    }
    if (calendar == null) {
        calendar = Calendar.getInstance(locale);
    }
    if (numberFormat == null) {
        NumberingSystem ns = NumberingSystem.getInstance(locale);
        if (ns.isAlgorithmic()) {
            numberFormat = NumberFormat.getInstance(locale);
        } else {
            String digitString = ns.getDescription();
            String nsName = ns.getName();
            // Use a NumberFormat optimized for date formatting
            numberFormat = new DateNumberFormat(locale, digitString, nsName);
        }
    }
    // Note: deferring calendar calculation until when we really need it.
    // Instead, we just record time of construction for backward compatibility.
    defaultCenturyBase = System.currentTimeMillis();

    setLocale(calendar.getLocale(ULocale.VALID_LOCALE ), calendar.getLocale(ULocale.ACTUAL_LOCALE));
    initLocalZeroPaddingNumberFormat();

    if (override != null) {
       initNumberFormatters(locale);
    }

    parsePattern();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:35,代码来源:SimpleDateFormat.java

示例6: 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

示例7: toLowerCase

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Returns the lowercase version of the argument string.
 * Casing is dependent on the argument locale and context-sensitive
 * @param locale which string is to be converted in
 * @param str source string to be performed on
 * @return lowercase version of the argument string
 * @stable ICU 3.2
 */
public static String toLowerCase(ULocale locale, String str) {
    StringContextIterator iter = new StringContextIterator(str);
    StringBuilder result = new StringBuilder(str.length());
    int[] locCache = new int[1];
    int c;

    if (locale == null) {
        locale = ULocale.getDefault();
    }
    locCache[0]=0;

    while((c=iter.nextCaseMapCP())>=0) {
        c = UCaseProps.INSTANCE.toFullLower(c, iter, result, locale, locCache);

        /* decode the result */
        if(c<0) {
            /* (not) original code point */
            c=~c;
        } else if(c<=UCaseProps.MAX_STRING_LENGTH) {
            /* mapping already appended to result */
            continue;
            /* } else { append single-code point mapping */
        }
        result.appendCodePoint(c);
    }
    return result.toString();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:36,代码来源:UCharacter.java

示例8: getBundleInstance

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
public static ICUResourceBundle getBundleInstance(
        String baseName, ULocale locale, OpenType openType) {
    if (locale == null) {
        locale = ULocale.getDefault();
    }
    return getBundleInstance(baseName, locale.getBaseName(),
            ICUResourceBundle.ICU_DATA_CLASS_LOADER, openType);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:9,代码来源:ICUResourceBundle.java

示例9: validateFallbackLocale

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Return the name of the current fallback locale.  If it has changed since this was
 * last accessed, the service cache is cleared.
 */
public String validateFallbackLocale() {
    ULocale loc = ULocale.getDefault();
    if (loc != fallbackLocale) {
        synchronized (this) {
            if (loc != fallbackLocale) {
                fallbackLocale = loc;
                fallbackLocaleName = loc.getBaseName();
                clearServiceCache();
            }
        }
    }
    return fallbackLocaleName;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:18,代码来源:ICULocaleService.java

示例10: readObject

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Override readObject.
 * See http://docs.oracle.com/javase/6/docs/api/java/io/ObjectInputStream.html
 */
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    int capitalizationSettingValue = (serialVersionOnStream > 1)? stream.readInt(): -1;
    ///CLOVER:OFF
    // don't have old serial data to test with
    if (serialVersionOnStream < 1) {
        // didn't have defaultCenturyStart field
        defaultCenturyBase = System.currentTimeMillis();
    }
    ///CLOVER:ON
    else {
        // fill in dependent transient field
        parseAmbiguousDatesAsAfter(defaultCenturyStart);
    }
    serialVersionOnStream = currentSerialVersion;
    locale = getLocale(ULocale.VALID_LOCALE);
    if (locale == null) {
        // ICU4J 3.6 or older versions did not have UFormat locales
        // in the serialized data. This is just for preventing the
        // worst case scenario...
        locale = ULocale.getDefault(Category.FORMAT);
    }

    initLocalZeroPaddingNumberFormat();

    setContext(DisplayContext.CAPITALIZATION_NONE);
    if (capitalizationSettingValue >= 0) {
        for (DisplayContext context: DisplayContext.values()) {
            if (context.value() == capitalizationSettingValue) {
                setContext(context);
                break;
            }
        }
    }

    // if serialized pre-56 update & turned off partial match switch to new enum value
    if(getBooleanAttribute(DateFormat.BooleanAttribute.PARSE_PARTIAL_MATCH) == false) {
        setBooleanAttribute(DateFormat.BooleanAttribute.PARSE_PARTIAL_LITERAL_MATCH, false);
    }

    parsePattern();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:48,代码来源:SimpleDateFormat.java

示例11: setLocale

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Sets the locale used by this <code>PluraFormat</code> object.
 * Note: Calling this method resets this <code>PluraFormat</code> object,
 *     i.e., a pattern that was applied previously will be removed,
 *     and the NumberFormat is set to the default number format for
 *     the locale.  The resulting format behaves the same as one
 *     constructed from {@link #PluralFormat(ULocale, PluralRules.PluralType)}
 *     with PluralType.CARDINAL.
 * @param ulocale the <code>ULocale</code> used to configure the
 *     formatter. If <code>ulocale</code> is <code>null</code>, the
 *     default <code>FORMAT</code> locale will be used.
 * @see Category#FORMAT
 * @deprecated ICU 50 This method clears the pattern and might create
 *             a different kind of PluralRules instance;
 *             use one of the constructors to create a new instance instead.
 */
@Deprecated
public void setLocale(ULocale ulocale) {
    if (ulocale == null) {
        ulocale = ULocale.getDefault(Category.FORMAT);
    }
    init(null, PluralType.CARDINAL, ulocale, null);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:24,代码来源:PluralFormat.java

示例12: getInstance

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * {@icu} Returns the Collator for the desired locale.
 *
 * <p>For some languages, multiple collation types are available;
 * for example, "[email protected]=phonebook".
 * Starting with ICU 54, collation attributes can be specified via locale keywords as well,
 * in the old locale extension syntax ("[email protected]=upper")
 * or in language tag syntax ("el-u-kf-upper").
 * See <a href="http://userguide.icu-project.org/collation/api">User Guide: Collation API</a>.
 *
 * @param locale the desired locale.
 * @return Collator for the desired locale if it is created successfully.
 *         Otherwise if there is no Collator
 *         associated with the current locale, the root collator will
 *         be returned.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 * @see #getInstance(Locale)
 * @see #getInstance()
 * @stable ICU 3.0
 */
public static final Collator getInstance(ULocale locale) {
    // fetching from service cache is faster than instantiation
    if (locale == null) {
        locale = ULocale.getDefault();
    }
    Collator coll = getShim().getInstance(locale);
    if (!locale.getName().equals(locale.getBaseName())) {  // any keywords?
        setAttributesFromKeywords(locale, coll,
                (coll instanceof RuleBasedCollator) ? (RuleBasedCollator)coll : null);
    }
    return coll;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:34,代码来源:Collator.java

示例13: RuleBasedNumberFormat

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Creates a RuleBasedNumberFormat that behaves according to the description
 * passed in.  The formatter uses the default <code>FORMAT</code> locale.
 * @param description A description of the formatter's desired behavior.
 * See the class documentation for a complete explanation of the description
 * syntax.
 * @see Category#FORMAT
 * @stable ICU 2.0
 */
public RuleBasedNumberFormat(String description) {
    locale = ULocale.getDefault(Category.FORMAT);
    init(description, null);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:14,代码来源:RuleBasedNumberFormat.java

示例14: DateFormatSymbols

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Constructs a DateFormatSymbols object by loading format data from
 * resources for the default <code>FORMAT</code> locale.
 *
 * @throws java.util.MissingResourceException if the resources for the default locale
 *          cannot be found or cannot be loaded.
 * @see Category#FORMAT
 * @stable ICU 2.0
 */
public DateFormatSymbols()
{
    this(ULocale.getDefault(Category.FORMAT));
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:14,代码来源:DateFormatSymbols.java

示例15: ChineseDateFormatSymbols

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Construct a ChineseDateFormatSymbols for the default <code>FORMAT</code> locale.
 * @see Category#FORMAT
 * @deprecated ICU 50
 */
@Deprecated
public ChineseDateFormatSymbols() {
    this(ULocale.getDefault(Category.FORMAT));
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:10,代码来源:ChineseDateFormatSymbols.java


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