The problem arises because scale
, the number of digits to the right of the decimal point, BigDecimal.ZERO
set to 0, and the scale
of zeroDollarValue
is 4.
The equals BigDecimal
method compares both scale and value - if they are different, it returns false.
Perhaps you can use
return selectPriceList.contains(BigDecimal.ZERO.setScale(4));
Assuming all your prices go up to four decimal places. If not, you may need to use
for(BigDecimal bd : selectPriceList) { if(bd.compareTo(BigDecimal.ZERO) == 0) { return true; } } return false;
See the documentation for more information.
source share