今天遇到個很棘手但難以解決的問題!就是關(guān)于Double顯示科學計數(shù)法問題!

比如10000000.21的Double類型 卻顯示成10.00000021E7 其實如果這個用String 類型輸出的話很容易解決。
如:
DecimalFormat df = new DecimalFormat("0.00");
System.out.println(df.format(a));
或
public static String formatNum(double value)
{
String retValue = null;
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
retValue = df.format(value);
retValue = retValue.replaceAll(",", "");
return retValue;
}
都可以不以科學計數(shù)法顯示的 但是返回的都是String 類型
大家有沒有考慮過。
如果讓Double類型不變的前提,非科學計數(shù)法顯示了。?
到最后實在沒辦法 。只有在頁面做文章了。
當在頁面獲取數(shù)據(jù)顯示前 ,對他格式化下!
用FMT:FORMATNUMBER 標簽;試試
具體寫法:
<fmt:formatNumber value="${caseForm.caseBean.payinfo.paymentFee}" pattern="0.00"/>