保留double后几位小数

   /**
     * double 类型取后面N位小数 N自定义.
     * @param nodesTemp
     * @return
     */
    public static String getNumDouble(double dou, int num) {
        String retValue = null;
        DecimalFormat df = new DecimalFormat();
        df.setMinimumFractionDigits(0);
        df.setMaximumFractionDigits(num);
        retValue = df.format(dou);
        retValue = retValue.replaceAll(",", "");
        return retValue;
    }
posted @ 2012-09-08 18:16  程序学习笔记  阅读(2346)  评论(0编辑  收藏  举报