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);
}
In the Above code out put is
Tesing1 0.007371 Tesing2 73.71 Tesing3 0.0073710000
But when i try to save it into database using hibernate its value become as 74. Doing rounding stub.
Does any one know what is reason.
Using this code i am saving the object
public boolean save(Object transInstance) {
boolean lSuccess = false;
getHibernateTemplate().save(transInstance);
lSuccess = true;
return lSuccess;
}
and this is .hbm file entry for that column and column defination in table
<property name="actlRsltPt" type="big_decimal">
<column name="ACTL_RSLT_PT" precision="6" scale="4" />
</property>
ACTL_RSLT_PT NUMBER (6,4)