List of utility methods to do BigDecimal from
BigDecimal | toBigDecimal(final Double d) Null save convert of a Double to a BigDecimal . if (d != null) { return BigDecimal.valueOf(d); } else { return null; |
BigDecimal | toBigDecimal(final Number n) to Big Decimal if (n == null || n instanceof BigDecimal) return (BigDecimal) n; if (n instanceof BigInteger) return new BigDecimal((BigInteger) n); return BigDecimal.valueOf(n.doubleValue()); |
BigDecimal | toBigDecimal(final Number number) to Big Decimal if (number instanceof Integer || number instanceof Long) { return new BigDecimal(number.longValue()); } else if (number instanceof Float || number instanceof Double) { return new BigDecimal(number.doubleValue()); } else { throw new RuntimeException( "Unexpected data type passed in to toBigDecimal (" + number.getClass() + ")"); |
BigDecimal | toBigDecimal(final Number number) To big decimal. if ((number instanceof Integer) || (number instanceof Long)) { return new BigDecimal(number.longValue()); } else if ((number instanceof Float) || (number instanceof Double)) { return new BigDecimal(number.doubleValue()); } else { throw new NumberFormatException( "Unexpected data type passed in to toBigDecimal (" + number.getClass() + ")"); |
BigDecimal | toBigDecimal(final Number number) to Big Decimal if (number == null) { return null; } else if (number instanceof BigDecimal) { return (BigDecimal) number; } else if (number instanceof Byte) { return new BigDecimal((Byte) number); } else if (number instanceof Short) { return new BigDecimal((Short) number); ... |
BigDecimal | toBigDecimal(final String bigdecimal) To big decimal. if (bigdecimal == null) { return null; if (bigdecimal.length() < 1) { return null; try { return new BigDecimal(bigdecimal); ... |
BigDecimal | toBigDecimal(final String string) to Big Decimal if (string == null || string.isEmpty()) { return BigDecimal.ZERO; return new BigDecimal(string); |
BigDecimal | toBigDecimal(final String value) to Big Decimal return new BigDecimal(value); |
BigDecimal | toBigDecimal(Integer num) to Big Decimal try { return roundBigDecimal(new BigDecimal(num)); } catch (Exception ignored) { return null; |
BigDecimal | toBigDecimal(JsonValue val) to Big Decimal if (val instanceof JsonNumber) { return ((JsonNumber) val).bigDecimalValue(); return new BigDecimal(toString(val)); |