public static int parseInt(String s) {
        //*** XML.decodeEntities relies on leading 0's being ignored 
        //    and number treated as decimal (not octal)

        //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 Integer.MAX_VALUE;
        s = s.trim();
        if (s.length() == 0)
            return Integer.MAX_VALUE;
        char ch = s.charAt(0);
        if ((ch < '0' || ch > '9') && ch != '-' && ch != '+' && ch != '.')
            return Integer.MAX_VALUE;

        //try to parse hex or regular int        
        try {
            if (s.startsWith("0x")) 
                return Integer.parseInt(s.substring(2), 16);
            return Integer.parseInt(s);
        } catch (Exception e) {      
            //falls through
        }

        //round from double?
        try {
            //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 ErddapMath2.roundToInt(Double.parseDouble(s));
        } catch (Exception e) {
            return Integer.MAX_VALUE;
        }
    }
public static int parseInt ( String s ) { if ( s == null ) return Integer . MAX_VALUE ; s = s . trim ( ) ; if ( s . length ( ) == 0 ) return Integer . MAX_VALUE ; char ch = s . charAt ( 0 ) ; if ( ( ch < '0' || ch > '9' ) && ch != '-' && ch != '+' && ch != '.' ) return Integer . MAX_VALUE ; try { if ( s . startsWith ( "0x" ) ) return Integer . parseInt ( s . substring ( 2 ) , 16 ) ; return Integer . parseInt ( s ) ; } catch ( Exception e ) { } try { return ErddapMath2 . roundToInt ( Double . parseDouble ( s ) ) ; } catch ( Exception e ) { return Integer . MAX_VALUE ; } }
Convert a string to an int.
Leading or trailing spaces are automatically removed.
This accepts hexadecimal integers starting with "0x".
Leading 0's (e.g., 0012) are ignored; number is treated as decimal (not octal as Java would).
Floating point numbers are rounded.
This won't throw an exception if the number isn't formatted right.
To make a string from an int, use ""+i, Integer.toHexString, or Integer.toString(i,radix).

@param s is the String representation of a number.
@return the int value from the String
(or Integer.MAX_VALUE if error).