原贴地址:https://bbs.youkuaiyun.com/topics/390418233
显示结果为小数点后保留2位,小数点前每3位一个逗号。
public String getDecimalFormat(String str){
Integer initValue=0;
String outStr = "";
if(str!=null&&!"".equals(str.trim())){
initValue=Integer.parseInt(str);
Integer yuanValue=initValue/100;
DecimalFormat fmt = new DecimalFormat("##,###,###,###,###.00");
double d;
try {
d = Double.parseDouble(String.valueOf(yuanValue));
outStr = fmt.format(d);
} catch (Exception e) {
e.printStackTrace();
}
}
return outStr;
}