How do I make 0 display as 0.00 using decimal format?
I am using the following code to display numbers with two decimal places and thousands of comma separators.
public static String formatNumber(double amount){
DecimalFormat formatter = new DecimalFormat("#,###.00");
return formatter.format(amount);
}
For other numbers this is fine, but 0 is returned as ".00" I want it to be "0.00". What do I need to change?
+3
source to share
2 answers