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