List of utility methods to do Double Number Truncate
double | truncateToTwoDecimals(double value) Truncate double value to 2 decimal places return value;
|
String | truncDouble(double val) trunc Double return String.valueOf(val).replaceAll("0+$", "").replaceAll("\\.$", ""); |
double | truncDouble(Double value, int decimals) Receive a double value and trunc decimals places char[] charValue = value.toString().toCharArray(); if (value.toString().contains("E")) { return value; StringBuilder buffer = new StringBuilder(charValue.length); int position = 0; while (charValue[position] != '.') { buffer.append(charValue[position]); ... |