Use java.text.DecimalFormat to format integer : Decimal « Data Type « Java






Use java.text.DecimalFormat to format integer

  

import java.text.DecimalFormat;

public class Main {

  public static void main(String args[]) {    
    System.out.println(new DecimalFormat("0.#####E0").format(123456));
  }
}
//1.23456E5

   
    
  








Related examples in the same category

1.Display the total amount of memory in the Java virtual machine.
2.Display the maximum amount of memory
3.Display the amount of free memory in the Java Virtual Machine.
4.Round number to fewer decimals
5.Display numbers with commas
6.Change the decimal separator is set to "."
7.Display numbers in scientific notation
8.new DecimalFormat("0.######E0")
9.Use new DecimalFormat("0.#####E0") to format double
10.new DecimalFormat("000000E0")
11.Display numbers with leading zeroes
12.Display a percentage
13.Display a currency value
14.new DecimalFormat(abc#)
15.DecimalFormat("00E00")
16.DecimalFormat("000E00")
17.DecimalFormat("0000000000E0")
18.new DecimalFormat("0.00")
19.new DecimalFormat("#.#")
20.new DecimalFormat("#.######") (1)
21.new DecimalFormat("#.000000")
22.new DecimalFormat(".######") (2)
23.new DecimalFormat("#,###,###") (grouping)
24.new DecimalFormat("##00")
25.Convert a number using the current Locale()
26.The 0 symbol shows a digit or 0 if no digit present
27.Use group separators and show trailing zeroes
28.Force minimum number of digits to left and right of decimal point
29.Set format to two decimal places: set Minimum Fraction Digits
30.Set format to two decimal places: set Maximum Fraction Digits
31.The . symbol indicates the decimal point
32.The , symbol is used to group numbers
33.The ; symbol is used to specify an alternate pattern for negative values
34.The ' symbol is used to quote literal symbols
35.DecimalFormat("00.00E0")
36.The number of #'s to the left of the decimal point sets the multiple of the exponent.
37.DecimalFormat("##E0") (exponent must be multiple of 2)
38.DecimalFormat("###E0") (exponent must be multiple of 3)
39.Extracts a decimal digit from a number