/**
* 金额格式化
* @param s 金额
* @param len 小数位数
* @return 格式后的金额
*/
public
static
String insertComma(String s,
int
len) {
if
(s ==
null
|| s.length() <
1
) {
return
""
;
}
NumberFormat formater =
null
;
double
num = Double.parseDouble(s);
if
(len ==
0
) {
formater =
new
DecimalFormat(
"###,###"
);
}
else
{
StringBuffer buff =
new
StringBuffer();
buff.append(
"###,###."
);
for
(
int
i =
0
; i < len; i++) {
buff.append(
"#"
);
}
formater =
new
DecimalFormat(buff.toString());
}
return
formater.format(num);
}