format a double with two decimal places as a string code example Example: how to format a double in java to 2 decimal places DecimalFormat df = new DecimalFormat("#.00");