> I use NumberFormat.getCurrencyInstance to get a formatter to display
> amounts. It automatically shows the amount with the currency symbol. I
> want amounts to be display in a column but without the symbol. Is it
> possible to do this simply ?
Don't use NumberFormat.getCurrencyInstance(), instead use DecimalFormat.
Like this:
import java.text.*;
public class Test {
public static void main(String[]args)
{
DecimalFormat fmt = new DecimalFormat("#,##0.00;(#,##0.00)");
double x = 0.01;
for(int i = 0;i < 12;i++) {
System.out.println(fmt.format(x));
x *= 10.0;
}
}
}
Result:
0.01
0.10
1.00
10.00
100.00
1,000.00
10,000.00
100,000.00
1,000,000.00
10,000,000.00
100,000,000.00
1,000,000,000.00

Signature
Paul Lutus
http://www.arachnoid.com
Lothar Kimmeringer - 29 Sep 2004 10:32 GMT
> Don't use NumberFormat.getCurrencyInstance(), instead use DecimalFormat.
Not good.
> DecimalFormat fmt = new DecimalFormat("#,##0.00;(#,##0.00)");
Only works for a subset of all available currencies.
Gruesse, Lothar

Signature
Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!
> I use NumberFormat.getCurrencyInstance to get a formatter to display
> amounts. It automatically shows the amount with the currency symbol. I
> want amounts to be display in a column but without the symbol. Is it
> possible to do this simply ?
>
> Thanks.
Hi - you could try numberformat.getNumberInstance and use the function
setMinimumFractionDigits(2)
HTH
Rob
wenyb a écrit :
> I use NumberFormat.getCurrencyInstance to get a formatter to display
> amounts. It automatically shows the amount with the currency symbol. I
> want amounts to be display in a column but without the symbol. Is it
> possible to do this simply ?
>
> Thanks.
Thanks for the answers.
Using DecimalFormat is indeed not good for the reason given by Lothar
Kimmeringer.
I found a way by calling setPositivePrefix("") and setPositiveSuffix("")
on the format returned by getCurrencyFormat. But I wonder if it covers
all the cases.
Thanks.
wenyb - 30 Sep 2004 22:05 GMT
wenyb a écrit :
> wenyb a écrit :
>
[quoted text clipped - 15 lines]
>
> Thanks.
For interested people, found a cleaner way using
DecimalFormatSymbols.setCurrencySymbol("")