I don’t think there is an API for that (I never needed it).
Your solution seams good to me, maybe you just add the constant ONE_HUNDRED
:
public static final BigDecimal ONE_HUNDRED = new BigDecimal(100);
public static BigDecimal percentage(BigDecimal base, BigDecimal pct){
return base.multiply(pct).divide(ONE_HUNDRED);
}
probably not that much gain, only if called very often
eventually put it in some Util class…