Java Number Format Pattern getNumberFormat(double d)

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

Description

format the double number

License

Open Source License

Parameter

Parameter Description
d a parameter

Declaration

public static double getNumberFormat(double d) 

Method Source Code

//package com.java2s;
/*//from   w ww. ja va2  s  .  c o  m
 * @(#)ModelStringUtil.java   
 *
 * Copyright (C) 2006-2011 www.interpss.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * @Author Mike Zhou
 * @Version 1.0
 * @Date 02/15/2008
 * 
 *   Revision History
 *   ================
 *
 */

import java.text.DecimalFormat;

public class Main {
    /**
     * format the double number
     *  
     * @param d
     * @return
     */
    public static double getNumberFormat(double d) {
        DecimalFormat format = new DecimalFormat("###0.000000");
        String str = "";
        str = format.format(d);
        double e = Double.parseDouble(str);
        return e;
    }
}

Related

  1. getNumber(final Map map, final Object key)
  2. getNumberComma(String number)
  3. getNumberFormat()
  4. getNumberFormat()
  5. getNumberFormat(BigDecimal num, final int digits)
  6. getNumberFormat(final String pattern)
  7. getNumberFormat(int maximumFractionDigits)
  8. getNumberFormat(String format, Locale locale)
  9. getNumberFormat(String localeStr)