Java Currency - getNumericCode() Method
The java.util.Currency.getNumericCode() method returns the ISO 4217 numeric code of this currency.
Syntax
public int getNumericCode()
Parameters
No parameter is required.
Return Value
Returns the ISO 4217 numeric code of this currency.
Exception
NA.
Example:
In the example below, the java.util.Currency.getNumericCode() method is used to get the ISO 4217 numeric code of the given currency.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a currency for UK locale Locale locale = Locale.UK; Currency Curr = Currency.getInstance(locale); //getting and printing the ISO 4217 currency code String CurrCode = Curr.toString(); System.out.println("ISO 4217 currency code is: " + CurrCode); //getting and printing the ISO 4217 numeric code int CurrNumCode = Curr.getNumericCode(); System.out.println("ISO 4217 numeric code is: " + CurrNumCode); } }
The output of the above code will be:
ISO 4217 currency code is: GBP ISO 4217 numeric code is: 826
❮ Java.util - Currency