java.util.Currency getDefaultFractionDigits()
Description
Method Syntax
public int getDefaultFractionDigits()
Method Returns
The getDefaultFractionDigits() method of Currency class returns the default number of fraction digits used with this currency.
Compatibility
Java 1.4
Java Currency getDefaultFractionDigits() Example
Below is a simple java example on the usage of getDefaultFractionDigits() method of Currency class.
package com.javatutorialhq.java.examples; import static java.lang.System.*; import java.util.Currency; /* * This example source code demonstrates the use of * getDefaultFractionDigits() method of Currency class. */ public class CurrencyGetCurrencyCodeExample { public static void main(String[] args) { // create an instance of Currency class Currency currency = Currency.getInstance("NZD"); // prints the default currency fraction digit of New Zealand Dollar out.println("Result="+currency.getDefaultFractionDigits()); } }
Basically on the above example, we just created a new Currency object with the Currency Code of NZD as method argument on the getInstance(). The NZD is the currency code of new zealand thus by invoking the method getDefaultFractionDigits() will give the default number of fraction digits for New Zealand Currency.