Check if BigDecimal value is in range
Lets make it generic:
public static <T extends Comparable<T>> boolean isBetween(T value, T start, T end) {
return value.compareTo(start) >= 0 && value.compareTo(end) <= 0;
}
That is achievable using the .compareTo() method. For instance:
if ( price.compareTo( BigDecimal.valueOf( 500 ) > 0
&& price.compareTo( BigDecimal.valueOf( 1000 ) < 0 ) {
// price is larger than 500 and less than 1000
...
}
Quoting (and paraphrasing) from the JavaDoc:
The suggested idiom for performing these comparisons is: (x.compareTo(y) op 0), where op is one of the six comparison operators [(<, ==, >, >=, !=, <=)]
Cheers,