Pattern Characters | Parsing |
Forcing + | Learning More |
Handling Negatives | Links |
Post-Processing |
Most Common DecimalFormat Pattern Characters | |
---|---|
Char | Meaning |
0 | digit or lead zeroes |
# | digit or nothing at all. There is no pattern character to provide lead spaces for creating a fixed length pattern. It also works to the right of the decimal point. It also suppresses the decimal point to the left if there is no fractional part. |
. | decimal point. Actual character displayed is locale-specific, though the character you specify for the pattern is always a dot, e. g. in Sweden this will display as a comma. |
, | comma for grouping digits. Actual character displayed is locale-specific, though the character you specify for the pattern is always a docomma, e. g. in Sweden this will display as a period. |
E | exponent separator. |
' | used to surround decorative characters, including embedded spaces, e. g. '$'###,##0.00 |
; | Used to separate the pattern for positive numbers from the pattern for negative numbers. |
% | display a ratio as a percentage. As in ##0.0%, multiplies the displayed value by 100 and displays a decorative trailing %. |
// Getting an explicit + - sign // Formats 3.0 as "+3.0" and -3.0 as "-3.0". // The surrounding ' are not needed in this case. DecimalFormat explicitSign = new DecimalFormat( "'+'0.0;'-'0.0" );
You can say something like this to arrange for negative numbers to be shown in parentheses:
This page is posted |
http://mindprod.com/jgloss/decimalformat.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\decimalformat.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.144.40.239] |
| |
Feedback |
You are visitor number | |