Here you can find the source of toDouble(String value)
Parameter | Description |
---|---|
value | A string representing a double value. |
Parameter | Description |
---|---|
NumberFormatException | if the string can't be parsed as an double value. |
public static double toDouble(String value) throws NumberFormatException
//package com.java2s; /*/* w ww . j a v a2s. c om*/ * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2008 - 2010, Geomatys * * This library 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 library 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 * Lesser General Public License for more details. */ public class Main { /** * Extends the {@link Double#valueOf(String)} method, in removing the leading * and trailing whitespace. * * @param value A string representing a double value. * @return A double representation of the given string, or {@code NaN} if the * given string is null. * @throws NumberFormatException if the string can't be parsed as an double value. */ public static double toDouble(String value) throws NumberFormatException { if (value == null) { return Double.NaN; } value = value.trim(); return Double.parseDouble(value); } }