0
private static DecimalFormat decimalFormat = new DecimalFormat("0.0000000000");
public static void main(String[] args) {
String str ="73.71" ;
BigDecimal decimal= new BigDecimal(str);
System.out.println("Tesing1 " + decimal.floatValue()/10000);
System.out.println("Tesing2 " + decimal.floatValue());
BigDecimal bigDecimal = new BigDecimal(decimalFormat.format(decimal.doubleValue()/ 10000));
System.out.println("Tesing3 " + bigDecimal);
}
在上面的代碼了說就是問題在十進制值
Tesing1 0.007371 Tesing2 73.71 Tesing3 0.0073710000
但是當我嘗試使用Hibernate的價值成爲74個將其保存到數據庫中。做四捨五入的存根。
是否有人知道是什麼原因。
使用此代碼我現在的儲蓄目標
public boolean save(Object transInstance) {
boolean lSuccess = false;
getHibernateTemplate().save(transInstance);
lSuccess = true;
return lSuccess;
}
,這是表
<property name="actlRsltPt" type="big_decimal">
<column name="ACTL_RSLT_PT" precision="6" scale="4" />
</property>
ACTL_RSLT_PT NUMBER (6,4)
表的模式是什麼? (並且你也有Hibernate的映射)? – Mark 2010-08-31 11:28:38
什麼是你的數據庫模式(你保存它的位置)?你的代碼寫入數據庫在哪裏? – atk 2010-08-31 11:29:16
如何將值存儲在數據庫中?該列有哪些類型? – 2010-08-31 11:30:14