I am trying to format prices using DecimalFormat, but this isn\'t working for all variations.
DecimalFormat df = new DecimalFormat(\"0.##\") df.format(7.8) d
This doesn't seem to be solved by a single formatter. I suggest you use "0.00" format and replace ".00" with an empty string.
formatter
"0.00"
".00"
public static String myFormat(double number) { DecimalFormat df = new DecimalFormat("0.00"); return df.format(number).replaceAll("\\.00$", ""); }