This example shows how to get the currency symbol for a given country in Java.
Currency class from the java.util package provides getSymbol method to find the currency symbol of a specific country from Locale instance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import java.util.Currency; import java.util.Locale; public class Main { public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.JAPAN); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); currency = Currency.getInstance(Locale.UK); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); currency = Currency.getInstance(Locale.US); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); currency = Currency.getInstance(new Locale("in", "ID")); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); } } |