I am using the following code to make numbers display with two decimal places and thousands comma separator.
public static String formatNumber(double amount){
DecimalFormat formatter = new DecimalFormat("#,###.00");
return formatter.format(amount);
}
For other numbers it is ok but 0 is returned as ".00" I want it to be "0.00" What should I change?
The #
means optional digit, so if you use 0
instead it will work:
DecimalFormat formatter = new DecimalFormat("#,##0.00");
BTW: I think you need 3 ###
not 4.