Java Currency.getDefaultFractionDigits() Method

 Posted On  | Yashwant Chavan 

In this tutorial, You will learn about Java Currency.getDefaultFractionDigits() Method. Gets the default number of fraction digits used with this currency. For example, the default number of fraction digits for the Euro is 2, while for the Japanese Yen it's 0. In the case of pseudo-currencies, such as IMF Special Drawing Rights, -1 is returned.

syntax

Gets the default number of fraction digits used with this currency.

int java.util.Currency.getDefaultFractionDigits()

Return

the default number of fraction digits used with this currency.

Java Currency.getDefaultFractionDigits() example

Refer below steps

  • Create Currency instance using Currency.getInstance(Locale locale) method.
  • Get fraction digits used by this currency using Currency.getDefaultFractionDigits() method.
package com.technicalkeeda.app;

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

public class JavaCurrencyGetDefaultFractionDigits {

    public static void main(String[] args) {

        Currency us = Currency.getInstance(Locale.US);
        System.out.println("Currency code US:- " + us.getDefaultFractionDigits());

        Currency uk = Currency.getInstance(Locale.UK);
        System.out.println("Currency code UK:- " + uk.getDefaultFractionDigits());

        Currency japan = Currency.getInstance(Locale.JAPAN);
        System.out.println("Currency code JAPAN:- " + japan.getDefaultFractionDigits());

    }
}

Output

Currency code US:- 2
Currency code UK:- 2
Currency code JAPAN:- 0


© technicalkeeda.com 2017

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0628 seconds.