Java Decimal Format decimalString(double d, boolean forceDigits)

Here you can find the source of decimalString(double d, boolean forceDigits)

Description

decimal String

License

Open Source License

Declaration

public static String decimalString(double d, boolean forceDigits) 

Method Source Code


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

import java.text.DecimalFormat;

public class Main {
    private static DecimalFormat df = new DecimalFormat("0.##");
    private static DecimalFormat dfForce = new DecimalFormat("00.00");

    public static String decimalString(double d, boolean forceDigits) {
        return forceDigits ? dfForce.format(d) : df.format(d);
    }/*from  ww  w.j av a  2 s  .c om*/
}

Related

  1. decimalFormat(Object obj)
  2. decimalFormat(String pattern)
  3. decimalFormat(String pattern, double value)
  4. decimalFormatLabel(final long value, final long divider, final String unit)
  5. decimalPointTwo(Float input)
  6. encodeDouble(double d)
  7. getCorrectionValue(double basicValue, int digit)
  8. getDecimalFormat()
  9. getDecimalFormat()