Home Help Java N Java Number Format
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java Number Format

Advertisement
In programming languages, a pattern of special characters is used to specify the format of the number. In java this is achieved by the java

Java Number Format

     

In programming languages, a pattern of special characters is used to specify the format of the number. In java this is achieved by the java.text.NumberFormat class. NumberFormat is the abstract base class for all number formats. It provides the interface for formatting and parsing numbers such as Strings to and from doubles and longs, and vice versa. It also helps you to format and parse numbers for any locale.
 
A format is given by a pattern of symbols. For example, the pattern "0.000" indicates that the number should begin with 0 if it is less than 1.0 and that the number of decimal places will be 3 and padded with 0 if necessary to reach 3 places.
 
Another example, the pattern "0.###" indicates that the number should begin with 0 if it is less than 1.0 and that the number of decimal places will be up to 3 and padded with blanks if the fraction needs less than 3 places.
  
Read example at:

http:/www.roseindia.net/java/beginners/DecimalFormatExample.shtml

 

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 27, 2009

Ask Questions?    Discuss: Java Number Format   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com