Search this blog

PL/SQL Tutorial - What is PL/SQL, Features and Advantages of PL/SQL

PL/SQL is developed by Oracle Corporation to increase/enhance capabilities of SQL, PL/SQL stands for P rocedural L anguage extension to SQ...

Thursday, 4 April 2013

Currency- A Java Utility, Get currency code , symbol using Locale in Java

Java provides utility classes inside java.util package.
java.util.Currency is very interesting class in this package,it represents currencies defined in ISO 4217 by 
their currency codes.
You can get currency codes, its symbol, default fraction digits using its method.

  extended by java.util.Currency 

see this short example , how we use Currency Class in Java,You can also get 
live currency fluctuation in java using Currency Converter API
package practiceJava;

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

public class CurrencyDemo {

    public static void main(String[] args) {
        // create a currency object with  locale
        Locale locale = Locale.US;
        Currency curr = Currency.getInstance(locale);
        System.out.println("Locale's currency code:" + curr.getCurrencyCode());
        // Get symbol for Currecny
        String symbol = curr.getSymbol();
        System.out.println("Symbol is :" + symbol);
        // Get default fraction digit for Currecny
        int frDigit = curr.getDefaultFractionDigits();
        System.out.println("Default fraction digit : " + frDigit);


Output look like this


  1. Excellent and very cool idea and the subject at the top of magnificence and I am happy to this post..Interesting post! Thanks for writing it.What's wrong with this kind of post exactly? It follows your previous guideline for post length as well as clarity.
    Java Training in Chennai

  2. The solution is another currency. In relative terms, if the dollar rises against another currency, that other currency boasts gone down up against the dollar.guarantor loans