public static boolean isNumeric ( String value , Locale locale ) { if ( value == null ) return false ; int start = 0 ; final DecimalFormatSymbols symbols = ( locale != null ) ? DecimalFormatSymbols . getInstance ( locale ) : DecimalFormatSymbols . getInstance ( ) ; if ( value . startsWith ( "+" ) || value . startsWith ( "-" ) ) start ++ ; boolean fraction = false ; for ( int i = start ; i < value . length ( ) ; i ++ ) { final char c = value . charAt ( i ) ; if ( c == symbols . getDecimalSeparator ( ) && ! fraction ) { fraction = true ; continue ; } if ( c == symbols . getGroupingSeparator ( ) && ! fraction ) { continue ; } if ( ! Character . isDigit ( c ) ) { return false ; } } return true ; }
Test if a string contains a parsable number .