Java Currency Name Get getLocalSymbol(Currency currency)

Here you can find the source of getLocalSymbol(Currency currency)

Description

Always returns the local symbol (for example $ or the euro symbol) of a currency, whatever the locale of the system is.

License

Mozilla Public License

Parameter

Parameter Description
currency the currency to get the local symbol

Return

the local symbol for the passed currency

Declaration

public static String getLocalSymbol(Currency currency) 

Method Source Code

//package com.java2s;
/*/*  w ww  . j  a v a 2  s.  c om*/
 * Copyright (c) 2012, Mayocat <hello@mayocat.org>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.util.Currency;
import java.util.Locale;
import java.util.SortedMap;

public class Main {
    public static SortedMap<Currency, Locale> currencyLocaleMap;

    /**
     * Always returns the local symbol (for example $ or the euro symbol) of a currency, whatever the locale of the
     * system is.
     *
     * @param currency the currency to get the local symbol
     * @return the local symbol for the passed currency
     */
    public static String getLocalSymbol(Currency currency) {
        return currencyLocaleMap.containsKey(currency) ? currency.getSymbol(currencyLocaleMap.get(currency))
                : currency.getSymbol();
    }
}

Related

  1. countryFlagForCurrency(String c)
  2. getDefaultCurrency()
  3. nameForCurrency(String currency)
  4. printCurrency(Currency value)