Java tutorial
//package com.java2s; /* * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007. * * Licensed under the Aduna BSD-style license. */ public class Main { /** * Parses the supplied xsd:double string and returns its value. * * @param s * A string representation of an xsd:double value. * @return The <tt>double</tt> value represented by the supplied string * argument. * @throws NumberFormatException * If the supplied string is not a valid xsd:double value. */ public static double parseDouble(String s) { s = trimPlusSign(s); return Double.parseDouble(s); } /** * Removes the first character from the supplied string if this is a plus * sign ('+'). Number strings with leading plus signs cannot be parsed by * methods such as {@link Integer#parseInt(String)}. */ private static String trimPlusSign(String s) { if (s.length() > 0 && s.charAt(0) == '+') { return s.substring(1); } else { return s; } } }