List of utility methods to do Number Convert
BigDecimal | convertToDecimal(Number n) convert To Decimal if (n instanceof BigDecimal) return (BigDecimal) n; else return new BigDecimal(n.toString()); |
double | convertToHours(long workingDuration) convert To Hours return BigDecimal.valueOf(workingDuration / (60.0 * 60.0 * 1000.0)).setScale(2, RoundingMode.HALF_UP)
.doubleValue();
|
Double | convertToInchesOfMercury(double altimeterSetting, String unit) convert To Inches Of Mercury if ("hPa".equalsIgnoreCase(unit) || "http://opengis.net/def/uom/UCUM/0/hPa".equalsIgnoreCase(unit)) { double convertedVal = 0.0295299830714 * altimeterSetting; return round(convertedVal, 2); return null; |
Object | convertToJBPM(Object value) A helper to convert result variables for jBPM. if (BigDecimal.class.isInstance(value)) { BigDecimal v = (BigDecimal) value; if (v.scale() == 0) { return v.intValue(); return v.doubleValue(); return value; ... |
double | convertToKg(int value) convert To Kg return BigDecimal.valueOf(value).divide(BigDecimal.valueOf(1000)).setScale(3).doubleValue();
|
long | convertToLong(String decimal, int precision) convert To Long if (Strings.isNullOrEmpty(decimal)) { return 0L; long time = 1L; for (int i = 0; i < precision; i++) { time = time * 10L; BigDecimal bigDecimal = new BigDecimal(decimal); ... |
double | ConvertToMeters(double distance) Convert To Meters return Round((distance * 0.2), 2);
|
int | convertToMm(double value) convert To Mm return BigDecimal.valueOf(value).multiply(BigDecimal.TEN).intValue();
|
String | convertToMoney(float money) convert To Money BigDecimal objB = new BigDecimal(Double.toString(money)); return objB.divide(BigDecimal.ONE, 2, BigDecimal.ROUND_HALF_UP).toString(); |
BigDecimal | getMoneyConversion(int money, int divisor) get Money Conversion BigDecimal a = new BigDecimal(money); BigDecimal b = new BigDecimal(divisor); return a.divide(b); |