方法一:
double myNum2 = 111231.5585478;
java.math.BigDecimal b = new java.math.BigDecimal(myNum2);
double myNum3 = b.setScale(5, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
System.out.println(myNum2);
System.out.println(myNum3);
方法二:
double d = 3.1465926;
String result = String.format("%.2f", d);
System.out.println(result);