Generally, this practice should be avoided. But since there is no utility method isValidBigDecimal(..)
, that’s the way to go.
As Peter Tillemans noted in the comments, place this code in a utility method called isValidBigDecimal(..)
. Thus your code will be agnostic of the way of determining the validity, and you can even later switch to another method.
Boris Pavlović suggested an option to check that using a 3rd party library (commons-lang). There’s one more useful method there, which I use whenever I need to verify numbers – NumberUtils.isNumber(..)