Java Utililty Methods Decimal Format

List of utility methods to do Decimal Format

Description

The list of methods to do Decimal Format are organized into topic(s).

Method

doubletrim(int degree, double d)
trim
String format = "#.#";
for (int i = 1; i < degree; i++) {
    format = format + "#";
DecimalFormat twoDForm = new DecimalFormat(format);
return Double.valueOf(twoDForm.format(d)).doubleValue();
doubletrim(int level, double value)
trim
StringBuilder sb = new StringBuilder("#.#");
for (int i = 0; i < level; i++)
    sb.append("#");
return Double.valueOf(new DecimalFormat(sb.toString()).format(value));
Doubletrim2Decimals(Double value)
trim Decimals
return Double.parseDouble(createDecimalFormatter("#.##").format(value));
Stringtruncate(double d)
Truncates a double to two places, and makes it a string.
return decFormat.format(d);