Java Fraction Format formatDouble(double value)

Here you can find the source of formatDouble(double value)

Description

format Double

License

Apache License

Declaration

public static String formatDouble(double value) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    protected static final NumberFormat formatter = new DecimalFormat("###.###");

    public static String formatDouble(double value) {
        return formatter.format(value);
    }//from   w w w. j  a  va2 s . c o m

    public static String formatDouble(double value, int n) {
        StringBuilder str = new StringBuilder("###.");
        for (int nn = 0; nn < n; nn++) {
            str.append("#");
        }
        NumberFormat newFormatter = new DecimalFormat(str.toString());
        return newFormatter.format(value);
    }
}

Related

  1. formatDouble(double number, int decimalDigits)
  2. formatDouble(double number, int integerDigits, int fractionDigits)
  3. formatDouble(double orig)
  4. formatDouble(Double someDouble)
  5. formatDouble(Double v)
  6. formatDouble(double value)
  7. formatDouble(double value, int precision)
  8. FormatDouble(final double dblValue, final int iNumLeft, final int iNumRight, final double dblMultiplier)
  9. formatDouble(Object obj)