public static Number createNumber ( String str ) throws ParseException { try { if ( str . indexOf ( ' ' ) != - 1 ) { return Double . valueOf ( str ) ; } 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 .