String strDouble = String.format("%.2f", 1.23456); DecimalFormat df = new DecimalFormat("#.##"); String formatted = df.format(2.456345); System.out.println(formatted);