How can I truncate a double to only two decimal places in Java?
If you want that for display purposes, use java.text.DecimalFormat: new DecimalFormat(“#.##”).format(dblVar); If you need it for calculations, use java.lang.Math: Math.floor(value * 100) / 100;