List of utility methods to do BigDecimal
double | getScaledDouble(BigDecimal input) get Scaled Double double retVal = 0; if (input != null) { retVal = input.setScale(SCALE, ROUNDING_MODE).doubleValue(); return retVal; |
BigDecimal | getSid(BigDecimal total, AtomicLong sid) get Sid BigDecimal ret = new BigDecimal(sid.getAndIncrement()); if (ret.longValue() > total.longValue()) { sid.set(1); return ret; |
String | getSignedBalance(BigDecimal balance) Utility method to add a sign to a balance getSignedBalance(100) returns "+100" getSignedBalance(-100) returns "-100" getSignedBalance(0) returns "0" String signedBalance = ""; if (balance.compareTo(BigDecimal.ZERO) > 0) { signedBalance += "+"; signedBalance += balance.setScale(2, RoundingMode.HALF_EVEN).toString(); return signedBalance; |
BigDecimal | getTensVal(BigDecimal val) get Tens Val return val.remainder(THOUSAND).remainder(HUNDRED); |
BigDecimal | getTotalSum(List Sum a list of sub totals to yield a total sum BigDecimal totalSum = new BigDecimal("0.00"); subTotals.forEach(subTotal -> totalSum.add(subTotal)); return totalSum; |
byte[] | getUnscaledBytes(BigDecimal bd) get Unscaled Bytes if (bd == null) { return Arrays.copyOf(NULL_INDICATOR, NULL_INDICATOR.length); final int scale = bd.scale(); final int precision = bd.precision(); if (scale > 12) { throw new IOException("Scale of " + bd + " is " + scale + " and the max is 12"); final int precisionMinusScale = precision - scale; if (precisionMinusScale > 26) { throw new IOException("Precision of " + bd + " to the left of the decimal point is " + precisionMinusScale + " and the max is 26"); final int scaleFactor = kDefaultScale - bd.scale(); BigInteger unscaledBI = bd.unscaledValue().multiply(scaleFactors[scaleFactor]); boolean isNegative = false; if (unscaledBI.signum() < 0) { isNegative = true; final byte unscaledValue[] = unscaledBI.toByteArray(); if (unscaledValue.length > 16) { throw new IOException("Precision of " + bd + " is >38 digits"); return expandToLength16(unscaledValue, isNegative); |
String | getUpdateAccountsQuery(BigDecimal[] result, int id) get Update Accounts Query return "UPDATE ACCOUNTS SET SUMB = " + result[0] + "," + "SUMD = " + result[1] + "," + "SUMT = " + result[2] + " " + "WHERE Aid = " + id; |
String | getUserLink(BigDecimal id, String name) Gets the user link. return "<a href='person.jsp?uid=" + id.toString() + "'>" + name + "</a>"; |
T | getValue(BigDecimal value, Class get Value return (T) value;
|
BigDecimal | getValue(String key, Map get Value BigDecimal value = BigDecimal.ZERO; if (valuesMap.containsKey(key)) { value = valuesMap.get(key); return value; |