java四舍五入

    if (runTimes > 24) {
                                                // 设置四舍五入,并保留两位小数
                                                NumberFormat numberInstance = NumberFormat.getNumberInstance();
                                                numberInstance.setMaximumFractionDigits(2);
                                                numberInstance.setRoundingMode(RoundingMode.UP); //四舍五入
                                                double tempTime = runTimes / 24;
                                                String tempData = numberInstance.format(tempTime);
                                                rtime = tempData + "Days";
                                            } else {
                                                rtime = runTimes + " H";
                                            }

  

原文地址:https://www.cnblogs.com/leigepython/p/10212837.html