Java Decimal Format toString(double value)

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

Description

Converts a double to a string without the trailing fractional zero.

License

Mozilla Public License

Parameter

Parameter Description
value Double value.

Return

String equivalent.

Declaration

public static String toString(double value) 

Method Source Code

//package com.java2s;
/**/*from  www  .j a  va2  s  .  c o m*/
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 
 * If a copy of the MPL was not distributed with this file, You can obtain one at 
 * http://mozilla.org/MPL/2.0/.
 * 
 * This Source Code Form is also subject to the terms of the Health-Related Additional
 * Disclaimer of Warranty and Limitation of Liability available at
 * http://www.carewebframework.org/licensing/disclaimer.
 */

import java.text.DecimalFormat;

public class Main {
    /**
     * Converts a double to a string without the trailing fractional zero.
     * 
     * @param value Double value.
     * @return String equivalent.
     */
    public static String toString(double value) {
        return new DecimalFormat("0.#################").format(value);
    }
}

Related

  1. toSplitDecimalString(Double num, int decimal)
  2. toStockPrice(double value)
  3. toString(double d)
  4. toString(double d)
  5. toString(double d, int precision)
  6. toString(double value)
  7. toString(double value)
  8. toString(double value, int precision)
  9. toString(double[] array)