代码示例
double num = 2.3333333; String numFixed = String.format("%.2f", num); System.out.println(numFixed); // 2.33
参考 Java – double保留两位小数的4种方法