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


Java LocaleData.getNumberFormatData方法代码示例

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


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

示例1: DecimalFormat

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
/**
 * Creates a DecimalFormat using the default pattern and symbols
 * for the default 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 java.text.NumberFormat#getInstance
 * @see java.text.NumberFormat#getNumberInstance
 * @see java.text.NumberFormat#getCurrencyInstance
 * @see java.text.NumberFormat#getPercentInstance
 */
public DecimalFormat() {
    Locale def = Locale.getDefault();
    // try to get the pattern from the cache
    String pattern = (String) cachedLocaleData.get(def);
    if (pattern == null) {  /* cache miss */
        // Get the pattern for the default locale.
        ResourceBundle rb = LocaleData.getNumberFormatData(def);
        String[] all = rb.getStringArray("NumberPatterns");
        pattern = all[0];
        /* update cache */
        cachedLocaleData.put(def, pattern);
    }

    // Always applyPattern after the symbols are set
    this.symbols = new DecimalFormatSymbols(def);
    applyPattern(pattern, false);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:33,代码来源:DecimalFormat.java

示例2: DecimalFormat

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
/**
 * Creates a DecimalFormat using the default pattern and symbols
 * for the default 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 java.text.NumberFormat#getInstance
 * @see java.text.NumberFormat#getNumberInstance
 * @see java.text.NumberFormat#getCurrencyInstance
 * @see java.text.NumberFormat#getPercentInstance
 */
public DecimalFormat() {
    Locale def = Locale.getDefault(Locale.Category.FORMAT);
    // try to get the pattern from the cache
    String pattern = cachedLocaleData.get(def);
    if (pattern == null) {  /* cache miss */
        // Get the pattern for the default locale.
        ResourceBundle rb = LocaleData.getNumberFormatData(def);
        String[] all = rb.getStringArray("NumberPatterns");
        pattern = all[0];
        /* update cache */
        cachedLocaleData.putIfAbsent(def, pattern);
    }

    // Always applyPattern after the symbols are set
    this.symbols = new DecimalFormatSymbols(def);
    applyPattern(pattern, false);
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:33,代码来源:DecimalFormat.java

示例3: getInstance

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private static NumberFormat getInstance(Locale desiredLocale,
                                       int choice) {
    // Check whether a provider can provide an implementation that's closer 
    // to the requested locale than what the Java runtime itself can provide.
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(NumberFormatProvider.class);
    if (pool.hasProviders()) {
        NumberFormat providersInstance = pool.getLocalizedObject(
                                NumberFormatGetter.INSTANCE,
                                desiredLocale,
                                choice);
        if (providersInstance != null) {
            return providersInstance;
        }
    }

    /* try the cache first */
    String[] numberPatterns = (String[])cachedLocaleData.get(desiredLocale);
    if (numberPatterns == null) { /* cache miss */
        ResourceBundle resource = LocaleData.getNumberFormatData(desiredLocale);
        numberPatterns = resource.getStringArray("NumberPatterns");
        /* update cache */
        cachedLocaleData.put(desiredLocale, numberPatterns);
    }

    DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(desiredLocale);
    int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE : choice;
    DecimalFormat format = new DecimalFormat(numberPatterns[entry], symbols);
    
    if (choice == INTEGERSTYLE) {
        format.setMaximumFractionDigits(0);
        format.setDecimalSeparatorAlwaysShown(false);
        format.setParseIntegerOnly(true);
    } else if (choice == CURRENCYSTYLE) {
        format.adjustForCurrencyDefaultFractionDigits();
    }

    return format;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:40,代码来源:NumberFormat.java

示例4: getInstance

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private static NumberFormat getInstance(Locale desiredLocale,
                                       int choice) {
    // Check whether a provider can provide an implementation that's closer
    // to the requested locale than what the Java runtime itself can provide.
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(NumberFormatProvider.class);
    if (pool.hasProviders()) {
        NumberFormat providersInstance = pool.getLocalizedObject(
                                NumberFormatGetter.INSTANCE,
                                desiredLocale,
                                choice);
        if (providersInstance != null) {
            return providersInstance;
        }
    }

    /* try the cache first */
    String[] numberPatterns = (String[])cachedLocaleData.get(desiredLocale);
    if (numberPatterns == null) { /* cache miss */
        ResourceBundle resource = LocaleData.getNumberFormatData(desiredLocale);
        numberPatterns = resource.getStringArray("NumberPatterns");
        /* update cache */
        cachedLocaleData.put(desiredLocale, numberPatterns);
    }

    DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(desiredLocale);
    int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE : choice;
    DecimalFormat format = new DecimalFormat(numberPatterns[entry], symbols);

    if (choice == INTEGERSTYLE) {
        format.setMaximumFractionDigits(0);
        format.setDecimalSeparatorAlwaysShown(false);
        format.setParseIntegerOnly(true);
    } else if (choice == CURRENCYSTYLE) {
        format.adjustForCurrencyDefaultFractionDigits();
    }

    return format;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:40,代码来源:NumberFormat.java

示例5: getDefaultPattern

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    ResourceBundle rb = LocaleData.getNumberFormatData(locale);
    String[] all = rb.getStringArray("NumberPatterns");
    return all[0];
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:7,代码来源:JSpinner.java


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