As in different sources, I think that the minimum length in the E-164 format depends on the country. For example,
... and so on. So, including the country code, the minimum length is 9 digits for Sweden and 11 for Israel and 8 for the Solomon Islands.
Change (clean solution) . In fact, instead of checking the international phone number using various checks, such as length, etc., you can use Google libphonenumber . It can directly check the phone number in E164 format. It will take into account everything, and you do not even need to indicate the country if the number is in the valid E164 format. It is very good! Example:
String phoneNumberE164Format = "+14167129018" PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); try { PhoneNumber phoneNumberProto = phoneUtil.parse(phoneNumberE164Format, null); boolean isValid = phoneUtil.isValidNumber(phoneNumberProto); // returns true if valid if (isValid) { // Actions to perform if the number is valid } else { // Do necessary actions if its not valid } } catch (NumberParseException e) { System.err.println("NumberParseException was thrown: " + e.toString()); }
If you know the country for which you are checking numbers, you do not even need the E164 format and you can specify the country in the .parse function instead of passing null .
Shobhit Puri Jul 23 '13 at 15:17 2013-07-23 15:17
source share