Java Currency Code Get getAvaiableCurrencySymbols()

Here you can find the source of getAvaiableCurrencySymbols()

Description

Returns all the currency symbols

License

Open Source License

Declaration

public synchronized static String[] getAvaiableCurrencySymbols() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2005 Sybase, Inc. and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from   ww w  .ja v  a 2  s.c o  m
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Locale;

public class Main {
    private static String[] _allCurrencySymbols;

    /**
      * Returns all the currency symbols
      * 
      * @return
      */
    public synchronized static String[] getAvaiableCurrencySymbols() {
        if (_allCurrencySymbols == null) {
            Locale[] locals = Locale.getAvailableLocales();
            ArrayList list = new ArrayList();
            for (int i = 0; i < locals.length; i++) {
                list.add(NumberFormat.getInstance(locals[i]).getCurrency().getSymbol(locals[i]));
            }
            _allCurrencySymbols = (String[]) list.toArray(new String[list.size()]);
            return _allCurrencySymbols;
        } else {
            return _allCurrencySymbols;
        }
    }
}

Related

  1. countryCodesForCurrency(String c)
  2. currencyFromCode(String currency)
  3. getCurrency(final String code)
  4. getCurrencyDisplay(Object amount)
  5. getCurrencyNationNumber(double num, int dec)
  6. getCurrencyString(long value)