Java Utililty Methods BigDecimal to

List of utility methods to do BigDecimal to

Description

The list of methods to do BigDecimal to are organized into topic(s).

Method

doubleconvertBigDecimalTodouble(BigDecimal bigDecimalVal)
Convert big decimal todouble.
if (bigDecimalVal != null) {
    return bigDecimalVal.doubleValue();
return 0;
byte[]convertBigDecimalToSQLBigNum(BigDecimal bd, int targetLength, int targetScale)
convert Big Decimal To SQL Big Num
byte[] sourceData = bd.setScale(targetScale, BigDecimal.ROUND_DOWN).unscaledValue().toString().getBytes(); 
byte[] targetData = new byte[targetLength];
int[] targetInShorts = new int[targetLength / 2];
int length;
int temp;
int tarPos = 1;
int zeros = 0;
while (zeros < sourceData.length && (sourceData[zeros] == '0' || sourceData[zeros] == '-'))
...
booleanconvertBigDecimalToString(BigDecimal bigValue)
convert Big Decimal To String
if (bigValue.intValue() == 0) {
    return false;
return true;
BigDecimalconvertDoubleToBigDecimal(Double value)
convert Double To Big Decimal
return new BigDecimal(Math.round(value));
BigDecimalconvertDoubleToBigDecimal(final Double score, final int decimalPlaces)
convert Double To Big Decimal
return new BigDecimal(score).setScale(10, RoundingMode.HALF_UP).setScale(decimalPlaces,
        RoundingMode.HALF_UP);
BigDecimalconvertFeetToInches(BigDecimal feet)
convert Feet To Inches
return feet.multiply(BigDecimal.valueOf(12));
BigDecimalconvertHoursToMillis(BigDecimal hours)
Number of hours = # of hours * 60 seconds * 60 minutes * 1000 millis
return hours.multiply(convertMinutesToMillis(new BigDecimal(60)));
BigDecimalconvertNullToBigDecimal(Object orgStr)
: convertNullToDate
if (orgStr == null || orgStr.toString().equals("")) {
    return new BigDecimal("0");
} else {
    return (BigDecimal) (orgStr);
BigDecimalconvertRadiansToDegrees(BigDecimal radians)
Converts the radians to degrees
return multiplyBy(radians, new BigDecimal(180 / PI));
BigDecimalconvertRating(BigDecimal rating)
convert Rating
if (rating == null) {
    return null;
int decimalPlaces = 2;
int r = 1;
for (int i = 0; i < decimalPlaces; i++) {
    r *= 10;
return BigDecimal.valueOf(Math.round((5 + rating.doubleValue() * (-4)) * r) / r);