DecimalFormat("0000000000E0") in Java


DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers. Let us set DecimalFormat("0000000000E0") first.

Format f = new DecimalFormat("0000000000E0");

Now, we will format a number and display the result in a string using the format() method −

String res = f.format(-97579.9146);

Since, we have used both Format and DecimalFormat class in Java, therefore importing the following packages in a must −

import java.text.DecimalFormat;
import java.text.Format;

The following is the complete example −

Example

 Live Demo

import java.text.DecimalFormat;
import java.text.Format;
public class Demo {
   public static void main(String[] argv) throws Exception {
      Format f = new DecimalFormat("0000000000E0");
      String res = f.format(-97579.9146);
      System.out.println(res);
   }
}

Output

-9757991460E-5

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jul-2019

41 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements