Java Double Number Format formatDouble(double d, int n, String pad)

Here you can find the source of formatDouble(double d, int n, String pad)

Description

format Double

License

GNU General Public License

Declaration

public static String formatDouble(double d, int n, String pad) 

Method Source Code

//package com.java2s;
/**//from ww w.  java 2 s  . co  m
 * This class was written by Stephen Crane (jscrane@gmail.com)
 * and is released under the terms of the GNU GPL
 * (http://www.gnu.org/licenses/gpl.html).
 */

public class Main {
    public static String formatDouble(double d, int n, String pad) {
        String s = Double.toString(d);
        int len = s.length();
        if (len > n)
            return s.substring(0, n);
        for (; len < n; len++)
            s = s + pad;
        return s;
    }
}

Related

  1. formatDouble(double d)
  2. formatDouble(double d)
  3. formatDouble(double d)
  4. formatDouble(double d, int n)
  5. formatDouble(double d, int n)
  6. formatDouble(double d, int precision)
  7. formatDouble(double inDouble, boolean inComma, int inCommaPos)
  8. formatDouble(double num, int width, int precision)
  9. FormatDouble(double p_value, int p_numberOfDecimalPlaces)