Here you can find the source of doubleToStr(double d)
public static String doubleToStr(double d)
//package com.java2s; /**/*w ww. ja va 2 s . c o m*/ * Copyright 2003 ZhongTian, Inc. All rights reserved. * * qingdao tec PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * $Id: DBUtil.java,v 1.1 2006/05/17 09:19:30 wiserd Exp $ * File:DBUtil.java * Date Author Changes * March 10 2003 wangdeliang Created */ public class Main { public static String doubleToStr(double d) { String rtn = ""; java.text.DecimalFormat df = new java.text.DecimalFormat("###0.000000"); rtn = df.format(d); return cutZero(rtn); } public static String cutZero(String v) { if (v.indexOf(".") > -1) { while (true) { if (v.lastIndexOf("0") == (v.length() - 1)) { v = v.substring(0, v.lastIndexOf("0")); } else { break; } } if (v.lastIndexOf(".") == (v.length() - 1)) { v = v.substring(0, v.lastIndexOf(".")); } } return v; } }