public static Number createNumber(String str) throws ParseException {
  try {
    if (str.indexOf('.') != -1) {
      return Double.valueOf(str);
    }
 else {
      return Long.valueOf(str);
    }
  }
 catch (  NumberFormatException e) {
    throw new ParseException(e.getMessage());
  }
}

public static Number createNumber ( String str ) throws ParseException { try { if ( str . indexOf ( '.' ) != - 1 ) { return Double . valueOf ( str ) ; } else { return Long . valueOf ( str ) ; } } catch ( NumberFormatException e ) { throw new ParseException ( e . getMessage ( ) ) ; } }
create a number from a string . if a . is present , it creates a double , otherwise a long .
