List of utility methods to do BigDecimal to
String | decimalToString(BigDecimal value) Creates a canonical string representation of the supplied BigDecimal value, whereby all string representations are lexicographically sortable. StringBuilder sb = new StringBuilder(); boolean negate = false; switch (value.signum()) { case -1: sb.append('-'); negate = true; break; case 1: ... |
String | toBeforeDecimalPointString(BigDecimal bigDecimal) to Before Decimal Point String String value = bigDecimal.toPlainString(); if (!value.contains(".")) { return bigDecimal.toPlainString(); String[] strings = value.split("\\."); return strings[0]; |
Double | toDouble(BigDecimal b, boolean allownull) to Double if (allownull && b == null) return null; return b.doubleValue(); |
double | toDouble(BigDecimal bigDecimal) to Double double result = 0.0; if (bigDecimal != null) { result = bigDecimal.doubleValue(); return result; |
Double | toDouble(final BigDecimal b) to Double if (b == null) { return null; String s = DecimalToS(b); return new Double(s); |
double | toDouble(final BigDecimal b) Null save convert of a BigDecimal to a double. if (b != null) { return b.doubleValue(); } else { return 0d; |
Long | toInteger(BigDecimal b) to Integer return b == null ? null : b.longValue();
|
Object | toLong(BigDecimal value) Returns the Long represented by the given value, or null if not an long value. Object number; try { number = value.scale() == 0 ? Long.valueOf(value.longValueExact()) : null; } catch (Exception e) { number = null; return number; |
Long | toLongObject(@Nullable final BigDecimal value) to Long Object return (value == null ? null : Long.valueOf(value.longValue()));
|
T | toNumber(final BigDecimal bigDecimal, final Class to Number if (bigDecimal == null) { return null; } else if (BigDecimal.class.isAssignableFrom(clazz)) { return (T) bigDecimal; } else if (Byte.class.isAssignableFrom(clazz)) { return (T) new Byte(bigDecimal.byteValue()); } else if (Short.class.isAssignableFrom(clazz)) { return (T) new Short(bigDecimal.shortValue()); ... |