bps计算保留两位小数展示

(cherry picked from commit 79de7b51df)
This commit is contained in:
tanghao
2019-01-22 08:54:11 +00:00
committed by 王鑫
parent 372232d206
commit 86365ad7b1
8 changed files with 18 additions and 12 deletions

View File

@@ -263,11 +263,12 @@ public class DashboardController extends BaseController{
list = gson.fromJson(fromJsonList.get("data").toString(), new TypeToken<List<TrafficIpActiveStatistic>>() {}.getType()) ;
if(list.size()>0) {
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//两个时间段之间的秒数
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
for(TrafficIpActiveStatistic data:list) {
data.setAvgByte(lf.format(Long.parseLong(data.get_byte())/1024/1024/1024/allSeconds));
data.setAvgByte(f.format(Long.parseLong(data.get_byte())/1024/1024/1024/allSeconds));
data.setAvgPacket(lf.format(Long.parseLong(data.get_packet())/allSeconds));
}
}