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";
                                            }

  

posted @ 2019-01-03 10:34  雷神约  阅读(243)  评论(0编辑  收藏  举报