how to parsing 10 digit number text into integer in java -
i have set "phone" int of 10 digit in database , take input text parse using
string phone1=request.getparameter("phone"); int phone =integer.parseint(phone1); but not work why?
in java can store in int variable numbers in range -2147483648 2147483647. not enough 10-digit telephone numbers. can fix using long:
long phone = long.parselong(phone1); on other hand rethink using number data types storing telephone numbers. why?
- because can't store leading zeros if numbers not 10 digits long.
- because loose formating, "123-456-..."
- because can't save things
#orp, valid used in phone numbers
Comments
Post a Comment