java double two decimal string code example
Example 1: java 2 decimals
double res = Math.round(a * 100) / 100;
Example 2: how to format a double in java to 2 decimal places
DecimalFormat df = new DecimalFormat("#.00");
double res = Math.round(a * 100) / 100;
DecimalFormat df = new DecimalFormat("#.00");