Reputation: 31
NumberFormat nf = new DecimalFormat("##,###.00");
String str = nf.format(0);
System.out.println(str);
If the num is not 0, the result is right.
but when num is 0,the result is .00,
How to make the result to 0.00?
Upvotes: 1
Views: 6555
Reputation: 86774
Use this number format instead:
NumberFormat nf = new DecimalFormat("##,##0.00");
^
|
Upvotes: 1