I do not know if this question has been already answered (apology if this is the case) or not for i have searched but to no avail. Here is the situation:
this is an example of the number :
I am using the following link for testing the numbers and writing the codes in java:
Phone Number entered: +23054721528
defaultCountry entered: MU
the international format becomes +230 5472 1528
normally the country code for this number is
country_code : 230 (country is Mauritius)
for the case of the country France the country_code will be 33
I also found and tried that any number starting with the country code can be formatted into international format just by adding the +sign at the start of the number without specifying
Here is the following example:
String testPhoneNum= "+23054721528"
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
PhoneNumber phNumber= phoneUtil.parse(testPhoneNum, "");
} catch (NumberParseException e) {
System.err.println("NumberParseException was thrown: " + e.toString());
}
with the above code the number is parsed correctly.
PROBLEM: I have numbers which do not start do not start with
country_code 230
example consider the previous number shown above '+23054721528'.
instead of having 23054721528, i just have the following number '54721528'.
No information about country code or even Phone Number Region (example MU). What i want to know is that how can i convert the number from 54721528' to atleast '+23054721528' without the use of country_code or Phone Number region.
I am using JAVA for the implementation and any help will be highly appreciated. If i had to consider only one country, it would have been much easier just by considering the length of the numbers but the problem is that this has to be implemented for phone numbers from more than one country (example France, India, Mauritius etc...)
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire