java.util.Currency getCurrencyCode()

Description

The getCurrencyCode() method of Currency class is use to get the ISO 4217 currency code of this currency.

Method Syntax

public String getCurrencyCode()

Method Argument

Data Type Parameter Description
N/A N/A N/A

Method Returns

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

Compatibility

Java 1.4

Java Currency getCurrencyCode() Example

Below is a simple java example on the usage of getCurrencyCode() method of Currency class.

package com.javatutorialhq.java.examples;


import static java.lang.System.*;

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


/*
 * This example source code demonstrates the use of 
 * getCurrencyCode() method of Currency class.
 */

public class CurrencyGetCurrencyCodeExample {

	public static void main(String[] args) {
		
		// create an instance of Currency class
		Currency currency = Currency.getInstance(Locale.FRANCE);
		// prints the Currency Code of France
		out.println(currency.getCurrencyCode());
	}
}

Basically on the above example, we just created a new Currency object with France as locale. Then we use the getCurrencyCode() to get the currency code pertaining to the Currency of France.

Sample Output

Below is the sample output when you run the above example.

Currency getCurrencyCode() Sample Output