コード例 #1
0
  private void initialize(Locale locale) {
    this.locale = locale;

    LocaleProviderAdapter adapter =
        LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);

    if (!(adapter instanceof ResourceBundleBasedAdapter)) {
      adapter = LocaleProviderAdapter.getResourceBundleBased();
    }

    Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData();

    String[] numberElements = (String[]) data[0];

    decimalSeparator = numberElements[0].charAt(0);

    groupingSeparator = numberElements[1].charAt(0);

    patternSeparator = numberElements[2].charAt(0);

    percent = numberElements[3].charAt(0);

    zeroDigit = numberElements[4].charAt(0);

    digit = numberElements[5].charAt(0);

    minusSign = numberElements[6].charAt(0);

    exponential = numberElements[7].charAt(0);

    exponentialSeparator = numberElements[7];

    perMill = numberElements[8].charAt(0);

    infinity = numberElements[9];

    NaN = numberElements[10];

    if (locale.getCountry().length() > 0) {
      try {
        currency = Currency.getInstance(locale);
      } catch (IllegalArgumentException e) {
      }
    }

    if (currency != null) {
      intlCurrencySymbol = currency.getCurrencyCode();

      if (data[1] != null && data[1] == intlCurrencySymbol) {
        currencySymbol = (String) data[2];
      } else {
        currencySymbol = currency.getSymbol(locale);

        data[1] = intlCurrencySymbol;

        data[2] = currencySymbol;
      }
    } else {
      intlCurrencySymbol = "XXX";

      try {
        currency = Currency.getInstance(intlCurrencySymbol);
      } catch (IllegalArgumentException e) {
      }
      currencySymbol = "\u00A4";
    }
    monetarySeparator = decimalSeparator;
  }
コード例 #2
0
 public static final DecimalFormatSymbols getInstance() {
   return getInstance(Locale.getDefault(Locale.Category.FORMAT));
 }
コード例 #3
0
 public DecimalFormatSymbols() {
   initialize(Locale.getDefault(Locale.Category.FORMAT));
 }