Different currencies can also place the currency symbol before or after the string, or have a different number of decimal places (if any). It is not really clear from your question how you want to handle those cases, but assuming you want to preserve those differences, try this.

Instead of just swapping in the currency symbol into your local number format, you could start with the foreign format and substitute the decimal format symbols with your local version. Those also include the currency, so you have to swap that back (don't worry, it's a copy).

public static NumberFormat localStyleForeignFormat(Locale locale) {
    NumberFormat format = NumberFormat.getCurrencyInstance(locale);
    if (format instanceof DecimalFormat) {
        DecimalFormat df = (DecimalFormat) format;
        // use local/default decimal symbols with original currency symbol
        DecimalFormatSymbols dfs = new DecimalFormat().getDecimalFormatSymbols();
        dfs.setCurrency(df.getCurrency());
        df.setDecimalFormatSymbols(dfs);
    }
    return format;
}

This way, you also retain the correct positioning of the currency symbol and the number of decimal places. Some examples, for default-Locale Locale.UK

en_GB   £500,000.00     £500,000.00
fr_FR   500 000,00 €    500,000.00 €
it_IT   € 500.000,00    € 500,000.00
ja_JP   ¥500,000       JPY500,000
hi_IN   रू ५००,०००.००    INR 500,000.00

If you also want to preserve the foreign currency symbol, instead of the local equivalent, use

localDfs.setCurrencySymbol(df.getCurrency().getSymbol(locale));
Answer from tobias_k on Stack Overflow
Top answer
1 of 2
20

Different currencies can also place the currency symbol before or after the string, or have a different number of decimal places (if any). It is not really clear from your question how you want to handle those cases, but assuming you want to preserve those differences, try this.

Instead of just swapping in the currency symbol into your local number format, you could start with the foreign format and substitute the decimal format symbols with your local version. Those also include the currency, so you have to swap that back (don't worry, it's a copy).

public static NumberFormat localStyleForeignFormat(Locale locale) {
    NumberFormat format = NumberFormat.getCurrencyInstance(locale);
    if (format instanceof DecimalFormat) {
        DecimalFormat df = (DecimalFormat) format;
        // use local/default decimal symbols with original currency symbol
        DecimalFormatSymbols dfs = new DecimalFormat().getDecimalFormatSymbols();
        dfs.setCurrency(df.getCurrency());
        df.setDecimalFormatSymbols(dfs);
    }
    return format;
}

This way, you also retain the correct positioning of the currency symbol and the number of decimal places. Some examples, for default-Locale Locale.UK

en_GB   £500,000.00     £500,000.00
fr_FR   500 000,00 €    500,000.00 €
it_IT   € 500.000,00    € 500,000.00
ja_JP   ¥500,000       JPY500,000
hi_IN   रू ५००,०००.००    INR 500,000.00

If you also want to preserve the foreign currency symbol, instead of the local equivalent, use

localDfs.setCurrencySymbol(df.getCurrency().getSymbol(locale));
2 of 2
7

You can specify the currency symbol on the NumberFormat with the setCurrency method.

Then simply use the Locale.UK to have the proper grouping separator displayed.

format.setCurrency(Currency.getInstance("EUR"));

Note that for a better handling of the grouping/decimal separator you might want to use a DecimalFormat instead.

DecimalFormatSymbols custom=new DecimalFormatSymbols();
custom.setDecimalSeparator('.');
custom.setGroupingSeparator(',');
DecimalFormat format = DecimalFormat.getInstance();
format.setDecimalFormatSymbols(custom);
format.setCurrency(Currency.getInstance("EUR"));

Then specify the correct pattern, example "€ ###,###.00".

🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Currency.html
Currency (Java Platform SE 8 )
4 days ago - If there is no currency available in the runtime, the returned set is empty. ... Gets the ISO 4217 currency code of this currency. ... Gets the symbol of this currency for the default DISPLAY locale. For example, for the US Dollar, the symbol is "$" if the default ...
🌐
Baeldung
baeldung.com › home › java › currency code to currency symbol mapping in java
Currency Code to Currency Symbol Mapping in Java | Baeldung
July 14, 2025 - Java offers multiple ways to map a currency code to its respective symbol, including the built-in Currency class, a hardcoded Map, and Locale support.
🌐
Medium
medium.com › @samuelgbenga972 › simplifying-multi-currency-support-in-java-a-smarter-way-to-handle-currency-symbols-659535de61f4
Simplifying Multi-Currency Support in Java: A Smarter Way to Handle Currency Symbols | by Samuelgbenga | Medium
May 9, 2025 - So, in real-world scenarios, you’ll likely need a third-party API (like IP-based geolocation services) to get the user’s actual region and then set the locale manually. However, for the sake of keeping this article short and focused, we’ll assume Locale.getDefault() returns the correct location/region. Java provides the Currency and Locale classes which let you display the appropriate currency symbol for a user's region without hardcoding or maintaining long mapping tables.
🌐
Kodejava
kodejava.org › how-do-i-change-the-currency-symbol
How do I change the currency symbol? - Learn Java by Examples
This example show you how to change the currency symbol for the defined locale using the DecimalFormatSymbols.setCurrencySymbol() method. After changing the currency symbol, the DecimalFormatSymbols instance is passed to the DecimalFormat object ...
🌐
Tabnine
tabnine.com › home page › code › java › java.util.currency
java.util.Currency.getSymbol java code examples | Tabnine
public void setCurrency(Currency currency) { setSymbol(this.address, UNUM_CURRENCY_SYMBOL, currency.getSymbol()); setSymbol(this.address, UNUM_INTL_CURRENCY_SYMBOL, currency.getCurrencyCode()); } origin: knowm/XChange · this.unicode = unicode; } else if (javaCurrency != null) { this.unicode = javaCurrency.getSymbol(); } else { this.unicode = commonCode; origin: robovm/robovm ·
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Java Currency Code Symbol Mapping Example - Java Code Geeks
May 8, 2025 - This article explores how to map currency codes to their symbols using these APIs. Java’s Currency class provides a getSymbol() method that returns the symbol for a given currency code, based on a specified locale.
Find elsewhere
🌐
Educative
educative.io › answers › how-to-convert-the-currency-code-to-the-currency-symbol-in-java
How to convert the currency code to the currency symbol in Java
Next we use the getSymbol() method on the currency object to get the currency symbol. ... To get all the available currency codes, use the static getAvailableCurrencies() method of the Currency class.
🌐
Oracle
docs.oracle.com › javase › tutorial › i18n › format › numberintro.html
Numbers and Currencies (The Java™ Tutorials > Internationalization > Formatting)
Using the factory methods provided by the NumberFormat class, you can get locale-specific formats for numbers, currencies, and percentages. With the DecimalFormat class you specify a number's format with a String pattern. The DecimalFormatSymbols class allows you to modify formatting symbols such as decimal separators and minus signs.
🌐
W3Resource
w3resource.com › java-tutorial › util › currency › java_currency_getsymbol.php
Java Currency Class: getSymbol() Method - w3resource
For example, for the US Dollar, the symbol is "$" if the default locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned. This is equivalent to calling getSymbol(Locale.getDefault(Locale.Category.DISPLAY)). ... import java.util.*; public class Main { public static void main(String args[]) { // Create a currency for INR Currency cur1 = Currency.getInstance("INR"); // Get and print the symbol of the currency String symbol = cur1.getSymbol(); System.out.println("Currency symbol is = " + symbol); } }
🌐
TutorialsPoint
tutorialspoint.com › java › util › currency_getsymbol_locale.htm
Java.util.Currency.getSymbol( Locale locale ) Method
package com.tutorialspoint; import java.util.*; public class CurrencyDemo { public static void main(String args[]) { // create a currency for uk locale Locale locale = Locale.UK; Currency curr = Currency.getInstance(locale); // get and print the symbol of the currency String symbol = curr.getSymbol(locale); System.out.println("Currency symbol is = " + symbol); } }
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.util.currency.symbol
Currency.Symbol Property (Java.Util) | Microsoft Learn
For example, for the US Dollar, the symbol is "$" if the default locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned. This is equivalent to calling #getSymbol(Locale) getSymbol(Locale.getDefault(Locale.Category.DISPLAY)). Java documentation for java.util.Currency.getSymbol().
Top answer
1 of 1
17

It says in the Currency specification:

getSymbol() gets the symbol of this currency for the default locale. For example, for the US Dollar, the symbol is "$" if the default locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned.

EDITED I have found a way around this issue

import java.util.Currency;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class CurrencyCode
{

    public static void main() {
        Map<Currency, Locale> map = getCurrencyLocaleMap();
        String [] countries = { "US", "CA", "MX", "GB", "DE", "PL", "RU", "JP", "CN" };

        for (String countryCode : countries) {
           Locale locale = new Locale("EN",countryCode);
           Currency currency = Currency.getInstance(locale);
           String symbol = currency.getSymbol(map.get(currency));
           System.out.println("For country " + countryCode + ", currency symbol is " + symbol);
        }
    }

    public static Map<Currency, Locale> getCurrencyLocaleMap() {
       Map<Currency, Locale> map = new HashMap<>();
        for (Locale locale : Locale.getAvailableLocales()) {
           try {
             Currency currency = Currency.getInstance(locale);
             map.put(currency, locale);
           }
           catch (Exception e){ 
             // skip strange locale 
           }
        }
        return map;
    }
}

This prints:

For country US, currency symbol is $
For country CA, currency symbol is $
For country MX, currency symbol is $
For country GB, currency symbol is £
For country DE, currency symbol is €
For country PL, currency symbol is zł
For country RU, currency symbol is руб.
For country SE, currency symbol is kr
For country JP, currency symbol is ¥
For country CN, currency symbol is ¥
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-convert-a-string-to-a-currency-format
Java Program to Convert a String to a Currency Format - GeeksforGeeks
July 23, 2025 - We create NumberFormat instances for each currency with the respective locales and set the currency using setCurrency(). We convert the string str to a BigDecimal object named amt.
🌐
Coderanch
coderanch.com › t › 665504 › java › create-custom-currency-format
How to create a custom currency format [Solved] (Java in General forum at Coderanch)
May 10, 2016 - Paul Clapham wrote:Maybe it's more of an intrusive solution than what you were looking for, but maybe Joda-Money might work for you? A friend forwarded me code that's perfect for what I need, if anyone else stumbles across this thread: http://stackoverflow.com/questions/10536899/how-to-set-customize-currency-in-java
🌐
Javatpoint
javatpoint.com › post › java-currency-getsymbol-method
Java Currency getSymbol() Method - Javatpoint
Java Currency getAvailableCurrencies() getCurrencyCode() getDefaultFractionDigits() getDisplayName() getInstance() getNumericCodeAsString() getNumericCode() getSymbol() toString()
🌐
Getaround Tech
getaround.tech › multi-currency-java
Multi-currency support in Java | Getaround Tech
But for some specific features we need client-side formatting, for instance an input field. Let’s dive into some Java APIs to see how they can help. First thing first, how to format a currency? The position of the currency symbol doesn’t depend on the currency itself, but on the country ...