w3resource

Java Currency Class: getCurrencyCode() Method

public String getCurrencyCode()

The getCurrencyCode() method is used to get the ISO 4217 currency code of a given currency.

Package: java.util

Java Platform: Java SE 8

Syntax:

getCurrencyCode()
Return Value:

The ISO 4217 currency code of this currency.

Return Value Type: String

Example: Java Currency class - getCurrencyCode() Method

The following example fills a Java Currency class: getCurrencyCode() Method

import java.util.*;
public class Main {
   public static void main(String args[]) {

      // create a currency with ETB code (ethiopian)
      Currency curr = Currency.getInstance("ETB");

      // Gets the ISO 4217 currency code and print it
      String cur_Code = curr.getCurrencyCode();
      System.out.println("Currency Code is = " + cur_Code);
   }
}

Output:

Currency Code is = ETB

Java Code Editor:

Previous:getAvailablecurrencies Method
Next:getDefaultfractiondigits Method



Follow us on Facebook and Twitter for latest update.