Java Decimal Format trim(int level, double value)

Here you can find the source of trim(int level, double value)

Description

trim

License

Open Source License

Declaration

public static double trim(int level, double value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;

public class Main {
    public static double trim(int level, double value) {
        StringBuilder sb = new StringBuilder("#.#");
        for (int i = 0; i < level; i++)
            sb.append("#");
        return Double.valueOf(new DecimalFormat(sb.toString()).format(value));
    }/*from  ww w  .j  a va2 s .c  o  m*/
}

Related

  1. toString(final double value, final int maxDecimalPlaces)
  2. toStringForHumans(double doubleToConvert)
  3. toStringNoDigits(double[] v)
  4. toStringScientific(double x)
  5. trim(int degree, double d)
  6. trim2Decimals(Double value)
  7. truncate(double d)