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?
"#,##0.00"
? – McwhirtersetGroupingUsed(true)
. This way you will automatically have the separator show for thousands, millions, billions, ... – Mcwhirter