Java.util.Currency.getCurrencyCode() Method


Advertisements


Description

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

Declaration

Following is the declaration for java.util.Currency.getCurrencyCode() method

public String getCurrencyCode()

Parameters

NA

Return Value

This method the ISO 4217 currency code of this currency.

Exception

NA

Example

The following example shows the usage of java.util.Currency.getCurrencyCode() method.

Live Demo
package com.tutorialspoint;

import java.util.*;

public class CurrencyDemo {
   public static void main(String args[]) {

      // create a currency with eur code
      Currency curr = Currency.getInstance("EUR");

      // get currency code and print it
      String curCode = curr.getCurrencyCode();
      System.out.println("Currency Code is = " + curCode);
   }
}

Let us compile and run the above program, this will produce the following result −

Currency Code is = EUR

java_util_currency.htm

Advertisements
E-Books Store