Java Currency.getInstance(Locale locale)

Syntax

Currency.getInstance(Locale locale) has the following syntax.

public static Currency getInstance(Locale locale)

Example

In the following code shows how to use Currency.getInstance(Locale locale) method.


//ww  w.ja  v a2s .c  o  m
import java.util.Currency;
import java.util.Locale;

public class Main {

   public static void main(String args[]) {

      // create a currency object with specified locale
      Locale locale = Locale.GERMANY;
      Currency curr = Currency.getInstance(locale);

      System.out.println("Locale's currency code:" + curr.getCurrencyCode());

   }
}

The code above generates the following result.