List of utility methods to do BigDecimal Create
BigDecimal | getBigDecimalOrNull(Object value) get Big Decimal Or Null if (!(value instanceof Number || value instanceof String)) { return null; if (!BigDecimal.class.isAssignableFrom(value.getClass())) { if (value instanceof Long || value instanceof Integer || value instanceof Short || value instanceof Byte || value instanceof AtomicLong || value instanceof AtomicInteger) { value = new BigDecimal(((Number) value).longValue(), MathContext.DECIMAL128); } else if (value instanceof BigInteger) { ... |
BigDecimal | getBigDecimalValue(Object o) Converts an object to a BigDecimal using the string representation of the object. if (o != null && o.toString().length() > 0) { return new BigDecimal(o.toString()); } else { return null; |
double | getDecimal(double a) get Decimal BigDecimal bd = new BigDecimal(a); bd = bd.setScale(3, BigDecimal.ROUND_HALF_UP); return bd.doubleValue(); |
String | getDecimal(Object[] data, int ordinal) get decimal data type data by ordinal This is for C++ SDK JNI don't support Decimal, so carbon convert decimal to string return ((BigDecimal) data[ordinal]).toString();
|
void | getDecimal(String clusive, int[] currentDecimal) get Decimal int length = 0; int decimal = 0; if (clusive != null && clusive.length() > 0) { try { BigDecimal bd = new BigDecimal(clusive); length = (bd.abs().toPlainString().length() + (bd.scale() > 0 ? -1 : 0)); if (bd.scale() > 0) { decimal = bd.scale(); ... |
BigDecimal | getDecimal(String number, BigDecimal def) Parse the given string into a big decimal if possible otherwise return the specified default. try { return new BigDecimal(number); } catch (Exception e) { return def; |
Double | getDecimalCoords(Integer degrees, Integer minutes, Integer seconds) Convert DMS format coordinate into decimal degrees, where W and S are indicated by negative degrees. Double deg = null; Double min = null; Double sec = null; if (degrees != null) { deg = Double.valueOf(degrees); if (minutes != null) { min = Double.valueOf(minutes); ... |
Number | getDecimalValue(String value, Object franctionDigits) get Decimal Value if (value == null || "".equals(value)) { return null; BigDecimal bigdecimal = new BigDecimal(value); if (franctionDigits != null && !franctionDigits.equals("")) { return bigdecimal.setScale(Integer.parseInt(franctionDigits.toString()), RoundingMode.HALF_UP); return bigdecimal.setScale(2, RoundingMode.HALF_UP); ... |
BigDecimal[] | getDecimalValues(String[] values, String dataType) get Decimal Values String[] dataArr = getValues(values, dataType); BigDecimal[] valueArr = new BigDecimal[dataArr.length]; int i = 0; for (String data : dataArr) { valueArr[i++] = new BigDecimal(data); return valueArr; |
BigDecimal | nullToBigDecimalZero(final Object obj) null To Big Decimal Zero if (obj == null || "".equals(obj.toString())) { return new BigDecimal("0"); } else { return new BigDecimal(obj.toString()); |