double num = 1.34567; System.out.format("%.4f", num);
DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(2); System.out.println(df.format(decimalNumber));