DecimalFormat Posted on: April 3, 2006 at 12:00 AM
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.
d">rightPad
or StringTools.toLZ.
Parsing: DecimalFormat
class also parses the String values to extract ints,
longs and doubles.
Ask Questions? Discuss: DecimalFormat
Post your Comment