- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Format integer values with java.text.DecimalFormat
Here, we are using the DecimalFormat class in Java to format integer value, which is the java.text.DecimalFormat package.
Let us take the following format: DecimalFormat("0.######E0") and use the format() method for this purpose −
new DecimalFormat("0.#####E0").format(5089) new DecimalFormat("0.#####E0").format(608)
Since, we have used DecimalFormat class in Java, therefore importing the following package in a must −
import java.text.DecimalFormat;
The following is an example −
Example
import java.text.DecimalFormat; public class Demo { public static void main(String[] argv) throws Exception { System.out.println(new DecimalFormat("0.#####E0").format(387979)); System.out.println(new DecimalFormat("0.#####E0").format(29797)); System.out.println(new DecimalFormat("0.#####E0").format(49788)); System.out.println(new DecimalFormat("0.#####E0").format(5089)); System.out.println(new DecimalFormat("0.#####E0").format(608)); System.out.println(new DecimalFormat("0.#####E0").format(20)); } }
Output
3.87979E5 2.9797E4 4.9788E4 5.089E3 6.08E2 2E1
- Related Articles
- Format double with new DecimalFormat("0.#####E0") in Java
- How to format message with integer fillers in Java
- Find integer in text data (comma separated values) with MySQL?
- DecimalFormat(abc#) in Java
- DecimalFormat("000000E0") in Java
- DecimalFormat("00.00E0") in Java
- DecimalFormat("##E0") in Java
- DecimalFormat("###E0") in Java
- DecimalFormat("00E00") in Java
- DecimalFormat("000E00") in Java
- DecimalFormat("0000000000E0") in Java
- DecimalFormat("0.######E0") in Java
- Java Program to format text in JTextPane
- Format currency with Java MessageFormat
- Define integer literals as octal values in Java

Advertisements