Java Currency.getCurrencyCode() Method

 Posted On  | Yashwant Chavan 

In this tutorial, You will learn about Java Currency.getCurrencyCode() Method. Which returns the ISO 4217 currency code of this currency.

syntax

Gets the ISO 4217 currency code of this currency.

String java.util.Currency.getCurrencyCode()

Return

return the ISO 4217 currency code of this currency.

Java Currency.getCurrencyCode() example

Refer below steps

  • Create Currency instance using Currency.getInstance(Locale locale) method.
  • Print currency code using Currency.getCurrencyCode() method.
package com.technicalkeeda.app;

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

public class JavaCurrencyGetCurrencyCode {

    public static void main(String[] args) {

        Currency us = Currency.getInstance(Locale.US);
        System.out.println("Currency code US:- " + us.getCurrencyCode());

        Currency uk = Currency.getInstance(Locale.UK);
        System.out.println("Currency code UK:- " + uk.getCurrencyCode());

    }
}

Output

Currency code US:- USD
Currency code UK:- GBP


© technicalkeeda.com 2017

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0216 seconds.