Hi there,
I would like to reactivate this topic because I seems to be more than just a formatting problem.
If I cannot rely on the fact, that hibernate provides values from db in a format I have set (e.g. 999.99), I cannot use calculating methods of BigDecimal without checking for the correct scale of the numbers.
I will try to explain it with to short examples:
Image that I put two values into Db. An amount and a taxPercentage. Leter I will retrieve them to do some calculations.
Code:
BigDecimal amount = new BigDecimal("100.00");
BigDecimal taxPercentage = new BigDecimal("27.00");
System.out.println(taxPercentage.divide(amount, BigDecimal.ROUND_HALF_UP));
The result will be 0.27 --> Thats correct for further processing!
--> Now put it into db
(...)
<-- Later get it from db
Code:
BigDecimal amount = getTaxPercentageFromDB();
BigDecimal taxPercentage = getAmountFromDB;
System.out.println(amount .divide(taxPercentage, BigDecimal.ROUND_HALF_UP));
The result will be zero! --> And thats my problem!
Has anyone an idea if there is a suitable solution?
Thanks!
[/code]