List of utility methods to do Number Convert
double | convertMB2GB(int valueMB) Convert a decimal MB(megabyte) to decimal GB(gigabyte) Officially, there are 1000 (10^3) megabytes (MB) in a gigabyte (GB) return (new BigDecimal(valueMB).divide(DECIMAL_KILO).doubleValue()); |
BigDecimal | convertMinutesToHours(Long minutes) convert Minutes To Hours if (minutes == null) { return BigDecimal.ZERO; } else { return new BigDecimal(minutes.doubleValue() / 60).setScale(1, BigDecimal.ROUND_HALF_UP); |
BigDecimal | convertNanoDiff(long startNanos, long stopNanos, TimeUnit timeUnit) convert Nano Diff BigDecimal diffNanos = new BigDecimal(stopNanos - startNanos); return diffNanos.divide(BigDecimal.valueOf(timeUnit.toNanos(1))); |
BigDecimal | convertNullToOne(final Object value) convert Null To One if (value == null) { return BigDecimal.ONE; if (value instanceof BigDecimal) { return (BigDecimal) value; return BigDecimal.valueOf(Double.valueOf(value.toString())); |
String | convertScientificToStandard(double value) convert Scientific To Standard return (new BigDecimal(Double.toString(value))).toPlainString(); |
String | convertSize(Long size) convert Size String retStr = ""; for (int i = 3; i > 0; i--) { double compSize = Math.pow(1024, i); double remainder = size / compSize; if (remainder > 1) { if (i == 3) { retStr = round(remainder, 2, BigDecimal.ROUND_HALF_EVEN) + "G"; break; ... |
String | convertSizeG1DetailsToSizeG1(final String size, final char units) Convert SIZE_G1_DETAILS to SIZE_G1. BigDecimal sizeG1 = new BigDecimal(size); char unitsG1; switch (units) { case 'B': sizeG1 = sizeG1.divide(new BigDecimal("1024")); unitsG1 = 'K'; break; case 'K': ... |
String | convertSizeToMB(long sizeInBytes) convert Size To MB double size = sizeInBytes / 1024; String m = " Kb"; if (size > 1024) { size = size / 1024; m = " MB"; BigDecimal bd = new BigDecimal(size); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); ... |
long | convertsToLong(double v) converts To Long BigDecimal b = new BigDecimal(v); return b.longValue(); |
Object | convertStringToObjectWrapper(String className, String value) Converts the string value to the specified wrapper class type Object o = null; if (className.equals("java.lang.Integer") || className.equals("int")) { o = new Integer(value); } else if (className.equals("java.lang.Long") || className.equals("long")) { o = Long.valueOf(value); } else if (className.equals("java.lang.Short") || className.equals("short")) { o = Short.valueOf(value); } else if (className.equals("java.lang.Byte") || className.equals("byte")) { ... |