java的NumberFormat使用

		try {
NumberFormat formater = NumberFormat.getNumberInstance();
formater.setMaximumFractionDigits(2);
formater.setMinimumFractionDigits(2);
ResultSet rs = GuoJiaBiaoZhunSqlServerConn.execSql(sql, false);
while(rs.next()){
DailyReportData rowData = new DailyReportData();
String area = StrUtils.secTrim(rs.getString(1));
for(int i = 0;i<summaryList.size();i++){
if(summaryList.get(i).getDay().indexOf(area)>=0){
rowData = summaryList.get(i);
break;
}
}
rowData.setJan(rs.getString(2)!=null?formater.format(rs.getDouble(2)):rs.getString(2));
rowData.setFeb(rs.getString(3)!=null?formater.format(rs.getDouble(3)):rs.getString(3));
rowData.setMar(rs.getString(4)!=null?formater.format(rs.getDouble(4)):rs.getString(4));
rowData.setApr(rs.getString(5)!=null?formater.format(rs.getDouble(5)):rs.getString(5));
rowData.setMay(rs.getString(6)!=null?formater.format(rs.getDouble(6)):rs.getString(6));
rowData.setJun(rs.getString(7)!=null?formater.format(rs.getDouble(7)):rs.getString(7));
rowData.setJul(rs.getString(8)!=null?formater.format(rs.getDouble(8)):rs.getString(8));
rowData.setAug(rs.getString(9)!=null?formater.format(rs.getDouble(9)):rs.getString(9));
rowData.setSep(rs.getString(10)!=null?formater.format(rs.getDouble(10)):rs.getString(10));
rowData.setOct(rs.getString(11)!=null?formater.format(rs.getDouble(11)):rs.getString(11));
rowData.setNov(rs.getString(12)!=null?formater.format(rs.getDouble(12)):rs.getString(12));
rowData.setDec(rs.getString(13)!=null?formater.format(rs.getDouble(13)):rs.getString(13));
rowData.setAtrr1(rs.getString(14)!=null?formater.format(rs.getDouble(14)):rs.getString(14));
//变幅
rowData.setAtrr2(rs.getString(15)!=null?formater.format(rs.getDouble(15)):rs.getString(15));
rowData.setAtrr3(rs.getString(16)!=null?formater.format(rs.getDouble(16)):rs.getString(16));
rowData.setAtrr4(rs.getString(17)!=null?formater.format(rs.getDouble(17)):rs.getString(17));
rowData.setAtrr5(rs.getString(18)!=null?formater.format(rs.getDouble(18)):rs.getString(18));

}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值