A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/java-tutorial/util/currency/java_currency_getdefaultfractiondigits.php below:

Website Navigation


Java Currency Class: getDefaultFractionDigits() Method

Java Currency Class: getDefaultFractionDigits() MethodLast update on August 19 2022 21:50:42 (UTC/GMT +8 hours) public int getDefaultFractionDigits()

The getDefaultFractionDigits() method is used to get the default number of fraction digits used with a given 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.

Package: java.util

Java Platform: Java SE 8

Syntax:

getDefaultFractionDigits()
Return Value:

The default number of fraction digits used with this currency

Return Value Type: int

Example:Java Currency class: getDefaultFractionDigits() Method

import java.util.*;

public class Main {
   public static void main(String args[]) {

      // create 2  currencies (Japan Yen and United States Dollar)
      Currency cur1 = Currency.getInstance("JPY");
      Currency cur2 = Currency.getInstance("USD");

      // Print their fraction digits
      int dg1 = cur1.getDefaultFractionDigits();
      System.out.println("JPY fraction digits: " + dg1);
      int dg2 = cur2.getDefaultFractionDigits();
      System.out.println("USD fraction digits: " + dg2);
   }
}

Output:

JPY fraction digits: 0
USD fraction digits: 2

Java Code Editor:

Previous:getCurrencycode Method
Next:getDisplayname Method


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4