Home Help Java D DecimalFormat
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

DecimalFormat

Advertisement
java.text.DecimalFormat is the class that is used for converting the decimal numbers into Strings.

DecimalFormat

     

java.text.DecimalFormat is the class that is used for converting the decimal numbers into Strings. This class is also used for parsing the Strings back in to binary numbers. It works with a String pattern to describe the format of a number. This class is used with doubles, floats, longs and ints. DecimalFormat automatically rounds off  to the number of decimal places.
  
Handling Negatives:
It does not arrange the minus sign of negative numbers. This arrangement is done automatically.

Post-Processing:
DecimalFormat class does not exactly do what you want, For that we have to add our own post-processing on the String it produces. Pad to fixed length with StringTools.leftPad or StringTools.rightPad or StringTools.toLZ.

Parsing:
DecimalFormat class also parses the String values to extract ints, longs and doubles.
Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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: April 3, 2006

Ask Questions?    Discuss: DecimalFormat  

Post your Comment


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