Example of Currency in Java
May 31, 2013
In Java, Currency denotes a country currency. Currency is identified by their currency code. The object of Currency can be obtained by Locale or currency code. Currency has methods getDefaultFractionDigits, getCurrencyCode and getSymbol.
CurrencyDemo.java
package com.util; import java.util.Currency; public class CurrencyDemo { public static void main(String[] args) { Currency c = Currency.getInstance("INR"); System.out.println(c.getDefaultFractionDigits()); System.out.println(c.getCurrencyCode()); System.out.println(c.getSymbol()); } }
2 INR INR