Java Double Number to String doubleToVisualString(double d)

Here you can find the source of doubleToVisualString(double d)

Description

Used to format doubles to two decimal places.

License

Open Source License

Parameter

Parameter Description
d the number to format

Return

the formatted number

Declaration

public static String doubleToVisualString(double d) 

Method Source Code


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

import java.text.DecimalFormat;

public class Main {
    /**/*w ww.j a  v  a  2s  .c  o  m*/
     * Used to format doubles to two decimal places. (i.e. 2.23)
     *
     * @param d the number to format
     * @return the formatted number
     */
    public static String doubleToVisualString(double d) {
        DecimalFormat decimalFormat = new DecimalFormat("#.##");
        return decimalFormat.format(d);
    }
}

Related

  1. doubleToString(double value, int maximum, int minimum)
  2. doubleToString(double value, String format)
  3. doubleToString(final double d, final int decimalPlaces)
  4. doubleToString(final double number)
  5. doubleToSz(double dval)