Java Utility Library

Java Currency - getCurrencyCode() Method



The java.util.Currency.getCurrencyCode() method returns the ISO 4217 currency code of this currency.

Syntax

public String getCurrencyCode()

Parameters

No parameter is required.

Return Value

Returns the ISO 4217 currency code of this currency.

Exception

NA.

Example:

In the example below, the java.util.Currency.getCurrencyCode() method is used to get the ISO 4217 currency code of the given currency.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a currency for Germany locale
    Locale locale = Locale.GERMANY;
    Currency Curr = Currency.getInstance(locale);

    //getting and printing the ISO 4217 currency code
    String CurrCode = Curr.getCurrencyCode();
    System.out.println("ISO 4217 currency code is: " + CurrCode);
  }
}

The output of the above code will be:

ISO 4217 currency code is: EUR

❮ Java.util - Currency