public boolean isNumber ( Object value ) { if ( value == null ) { return false ; } if ( value instanceof Number ) { return true ; } // valid Long? if ( String . valueOf ( value ) . matches ( "\\d+" ) ) { return true ; } try { // valid Double? Double . parseDouble ( String . valueOf ( value ) ) ; } catch ( Exception e ) { return false ; } return true ; }
Returns true iff value is a Number .