code: private static boolean isInteger( Number n ) {
        if( n instanceof Integer ){
           return true;
        }
        try{
           Integer.parseInt( String.valueOf( n ) );
           return true;
        }catch( NumberFormatException e ){
           return false;
        }
     }
docs: Finds out if n represents an Integer.
  
  @return true if n is instanceOf Integer or the literal value can be
  evaluated as an Integer.