java.util.Currency.getDefaultFractionDigits()
The method java.util.Currency.getDefaultFractionDigits() gets the default number of fraction digits used with this currency.
Method signature
The signature of the java.util.Currency.getDefaultFractionDigits() method is as follows:
public int getDefaultFractionDigits()
Parameters
The method takes no parameters.
Return value
Returns the default number of fraction digits used with this currency. -1 for pseudo currencies.
Exceptions
The method throws no exceptions.
Example usage
In the following code we use java.util.Currency.getDefaultFractionDigits():
package com.farenda.java.util; import java.util.Currency; import java.util.Locale; public class CurrencyDefaultFractionDigits { public static void main(String[] args) { Locale locale = Locale.FRANCE; Currency currency = Currency.getInstance(locale); System.out.printf("Fraction digits of %s: %d%n", currency, currency.getDefaultFractionDigits()); locale = Locale.JAPAN; currency = Currency.getInstance(locale); System.out.printf("Fraction digits of %s: %d%n", currency, currency.getDefaultFractionDigits()); currency = Currency.getInstance("XBC"); System.out.printf("Fraction digits of %s: %d%n", currency, currency.getDefaultFractionDigits()); } }
The above code produces the following output:
Fraction digits of EUR: 2 Fraction digits of JPY: 0 Fraction digits of XBC: -1