首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

有现成的步骤把数字换成金额格式999,999,999的吗,就是每三位逗好隔开

2011-11-29 
有现成的方法把数字换成金额格式999,999,999的吗,就是每三位逗好隔开?[解决办法]DecimalFormat myFormatte

有现成的方法把数字换成金额格式999,999,999的吗,就是每三位逗好隔开
?

[解决办法]

DecimalFormat myFormatter = new DecimalFormat( "###,###,###.## ");
String output = myFormatter.format(value);
System.out.println(output);

[解决办法]
要带改成其他货币符号的话,改里面的“$”就可以了。

String str = String.format( "$%,.2f ", num + 0.0);
System.out.println(str);
[解决办法]
public String getCurrency (String aCurrency)
{ if (aCurrency == null || aCurrency.length() == 0)
return " ";
try
{
double dCurr= Double.parseDouble(aCurrency);
dCurr /= 100;
java.text.DecimalFormat dFmt= new java.text.DecimalFormat( "#,##0.00 ");
return dFmt.format(dCurr);
}
catch (Exception ex)
{
return aCurrency;
}
}

自己写个bean放到top.jsp里
以后每个jsp页面include这个top.jsp
调用这个方法就可以
just try

热点排行