Java Data Type Tutorial - 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.

//from  w w  w.ja  v  a 2 s.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.