waterml/src/main/java/ucar/nc2/ogc/erddap/util/ErddapString2.java
public static double parseDouble(String s) {
        //quickly reject most non-numbers
        //This is a huge speed improvement when parsing ASCII data files
        //  because Java is very slow at filling in the stack trace when an exception is thrown.
        if (s == null)
            return Double.NaN;
        s = s.trim();
        if (s.length() == 0)
            return Double.NaN;
        char ch = s.charAt(0);
        if ((ch < '0' || ch > '9') && ch != '-' && ch != '+' && ch != '.')
            return Double.NaN;

        try {
            if (s.startsWith("0x")) 
                return Integer.parseInt(s.substring(2), 16);

            //2011-02-09 Bob Simons added to avoid Java hang bug.
            //But now, latest version of Java is fixed.
            //if (isDoubleTrouble(s)) return 0;  
            
            return Double.parseDouble(s);
        } catch (Exception e) {
            return Double.NaN;
        }
    }
public static double parseDouble(String s) {
        //quickly reject most non-numbers
        //This is a huge speed improvement when parsing ASCII data files
        //  because Java is very slow at filling in the stack trace when an exception is thrown.
        if (s == null)
            return Double.NaN;
        s = s.trim();
        if (s.length() == 0)
            return Double.NaN;
        char ch = s.charAt(0);
        if ((ch < '0' || ch > '9') && ch != '-' && ch != '+' && ch != '.')
            return Double.NaN;

        try {
            if (s.startsWith("0x")) 
                return Integer.parseInt(s.substring(2), 16);

            //2011-02-09 Bob Simons added to avoid Java hang bug.
            //But now, latest version of Java is fixed.
            //if (isDoubleTrouble(s)) return 0;  
            
            return Double.parseDouble(s);
        } catch (Exception e) {
            return Double.NaN;
        }
    }
public static double parseDouble ( String s ) { //quickly reject most non-numbers //This is a huge speed improvement when parsing ASCII data files //  because Java is very slow at filling in the stack trace when an exception is thrown. if ( s == null ) return Double . NaN ; s = s . trim ( ) ; if ( s . length ( ) == 0 ) return Double . NaN ; char ch = s . charAt ( 0 ) ; if ( ( ch < ' ' || ch > ' ' ) && ch != ' ' && ch != ' ' && ch != ' ' ) return Double . NaN ; try { if ( s . startsWith ( "0x" ) ) return Integer . parseInt ( s . substring ( 2 ) , 16 ) ; //2011-02-09 Bob Simons added to avoid Java hang bug. //But now, latest version of Java is fixed. //if (isDoubleTrouble(s)) return 0;   return Double . parseDouble ( s ) ; } catch ( Exception e ) { return Double . NaN ; } }
Convert a string to a double.
Leading or trailing spaces are automatically removed.
This accepts hexadecimal integers starting with "0x".
Whole number starting with '0' (e.g., 012) is treated as decimal (not octal as Java would).
This won't throw an exception if the number isn't formatted right.

@param s is the String representation of a number.
@return the double value from the String (a finite value,
Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
or Double.NaN if error).
Convert a string to a double . Leading or trailing spaces are automatically removed . This accepts hexadecimal integers starting with 0x . Whole number starting with 0 ( e . g . 012 ) is treated as decimal ( not octal as Java would ) . This won t throw an exception if the number isn t formatted right .