Home Help Java N Java Number Format



Java Number Format
Posted on: May 27, 2009 at 12:00 AM
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

 

Related Tags for Java Number Format:
cclassormformformattracnumberabstractforbaseenumberformatbstrrmasmtrclaseallsbstatracisllactstrssthstabo


More Tutorials from this section

Ask Questions?    Discuss: Java Number Format   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.