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:float string and returns its value. * * @param s * A string representation of an xsd:float value. * @return The <tt>float</tt> value represented by the supplied string * argument. * @throws NumberFormatException * If the supplied string is not a valid xsd:float value. */ public static float parseFloat(String s) { s = trimPlusSign(s); return Float.parseFloat(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; } } }