`
wpf523
  • 浏览: 22859 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

格式化显示数字

 
阅读更多

//格式化

List list = new ArrayList() ;

DecimalFormat myFormat = new DecimalFormat("###,##0.000000");

DecimalFormat myFormat1 = new DecimalFormat("###,##0.0");

String value = "" ;

list.add("Long0") ;

list.add("Short0") ;

list.add("Current0") ;

for(int i=0 ;i<list.size();i++){

for(int j=1; j<=4; j++){

if(getDoubleValue("income01"+list.get(i)+j) == 0){

value = myFormat1.format(getDoubleValue("income01"+list.get(i)+j)) ;

request.setAttribute("income01"+list.get(i)+j, value) ;

}else{

value = myFormat.format(getDoubleValue("income01"+list.get(i)+j)) ;

request.setAttribute("income01"+list.get(i)+j, value) ;

}

if(getDoubleValue("cost01"+list.get(i)+j) == 0){

value = myFormat1.format(getDoubleValue("cost01"+list.get(i)+j)) ;

request.setAttribute("cost01"+list.get(i)+j, value) ;

}else{

value = myFormat.format(getDoubleValue("cost01"+list.get(i)+j)) ;

request.setAttribute("cost01"+list.get(i)+j, value) ;

}

if(getDoubleValue("profit01"+list.get(i)+j) == 0){

value = myFormat1.format(getDoubleValue("profit01"+list.get(i)+j)) ;

request.setAttribute("profit01"+list.get(i)+j, value) ;

}else{

value = myFormat.format(getDoubleValue("profit01"+list.get(i)+j)) ;

request.setAttribute("profit01"+list.get(i)+j, value) ;

}

}  //end for

}//end for

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics