Java Currency.getInstance(Locale locale) Method

 Posted On  | Yashwant Chavan 

In this tutorial, You will learn about Java Currency.getInstance(Locale locale) Method. Returns the Currency instance for the country of the given locale. The language and variant components of the locale are ignored. The result may vary over time, as countries change their currencies. For example, for the original member countries of the European Monetary Union, the method returns the old national currencies until December 31, 2001, and the Euro from January 1, 2002, local time of the respective countries.


Returns the Currency instance for the country of the given locale

Currency java.util.Currency.getInstance(Locale locale)


locale the locale for whose country a Currency instance is needed.


the Currency instance for the country of the given locale, or null.


NullPointerException - if locale or its country code is null.

IllegalArgumentException - if the country of the given locale is not a supported ISO 3166 country code.

Java Currency.getInstance(Locale locale) example

Refer below steps

  • Create Currency instance using Currency.getInstance(Locale locale) method and print respected currency code.

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

public class JavaCurrencyGetInstance {

    public static void main(String[] args) {

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

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

        Currency japan = Currency.getInstance(Locale.JAPAN);
        System.out.println("Currency code JAPAN:- " + japan);



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

© 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0287 seconds.