user3163839
user3163839

Reputation: 31

How to format the number .00 to 0.00?

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

Answers (1)

Jim Garrison
Jim Garrison

Reputation: 86774

Use this number format instead:

NumberFormat nf = new DecimalFormat("##,##0.00");  
                                          ^
                                          |

Upvotes: 1

Related Questions