关于Double显示科学计数法问题!
比如10000000.21的Double类型 却显示成10.00000021E7 其实如果这个用String 类型输出的话很容易解决。
如:
DecimalFormat df =newDecimalFormat("0.00");
System.out.println(df.format(a));
或
public static String formatNum(double value){
String retValue =null;
DecimalFormat df =newDecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
retValue = df.format(value);
retValue = retValue.replaceAll(",","");
returnretValue;
}
都可以不以科学计数法显示的 但是返回的都是String 类型
大家有没有考虑过。
如果让Double类型不变的前提,非科学计数法显示了。?
到最后实在没办法 。只有在页面做文章了。
当在页面获取数据显示前 ,对他格式化下!
用FMT:FORMATNUMBER 标签;试试
具体写法:
原文传送门:http://www.blogjava.net/javacql/archive/2009/11/13/302168.html
网友评论