List of utility methods to do BigDecimal to
byte[] | bigDecimalToByte(BigDecimal num) This method will convert a big decimal value to bytes BigInteger sig = new BigInteger(num.unscaledValue().toString()); int scale = num.scale(); byte[] bscale = new byte[] { (byte) (scale) }; byte[] buff = sig.toByteArray(); byte[] completeArr = new byte[buff.length + bscale.length]; System.arraycopy(bscale, 0, completeArr, 0, bscale.length); System.arraycopy(buff, 0, completeArr, bscale.length, buff.length); return completeArr; ... |
byte[] | bigDecimalToBytes(BigDecimal decimal) This function converts a big decimal to its corresponding byte array format. String string = decimal.toString();
return stringToBytes(string);
|
String | bigDecimalToDbString(BigDecimal bd) Converts the BigDecimal bd into something formatted properly for MySQL. return (bd == null) ? "NULL" : bd.toString(); |
Integer | bigDecimalToInteger(BigDecimal value) big Decimal To Integer if (value != null) { return new Integer(value.intValue()); return null; |
String | bigDecimaltoJSONString(Object obj) bigDecimaltoJSONString BigDecimal number = (BigDecimal) obj;
return number.toString();
|
Long | bigDecimalToLong(BigDecimal bigDecimal) big Decimal To Long bigDecimal.setScale(DECIMAL_SCALE, ROUNDING_MODE);
return bigDecimal.multiply(SATOSHIS).longValue();
|
Long | bigDecimalToLong(BigDecimal value) big Decimal To Long return value.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
|
String | bigDecimalToStellarBalance(final BigDecimal balance) big Decimal To Stellar Balance return balance.toString();
|
String | bigDecimalToString(BigDecimal bigDecimal) big Decimal To String if (bigDecimal == null) { return ""; return bigDecimal.toString(); |
String | bigDecimalToString(BigDecimal dec) big Decimal To String if (dec == null) { return "0"; if (dec.toString().length() < 10) { return dec.toString(); return dec.toString().substring(0, 10) + dec.toString().substring(dec.toString().length() - 6); |