Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.google.i18n.phonenumbers Bug?

As far as I know BRAZIL COUNTRY CODE is +55

But this piece of code

mobilePhoneNumber = "+32495665962";
            isoCode = "BR";

            phoneNumber = phoneNumberUtil.parse(mobilePhoneNumber, isoCode);
            isValid = phoneNumberUtil.isValidNumber(phoneNumber);
            phoneNumberType = phoneNumberUtil.getNumberType(phoneNumber);

            System.out.println ("phoneNumber ----- > " + phoneNumber);
            System.out.println ("isValid --------- > " + isValid);
            System.out.println ("phoneNumberType - > " + phoneNumberType);

gives me that number as valid !

phoneNumber ----- > Country Code: 32 National Number: 495665962
isValid --------- > true
phoneNumberType - > MOBILE
like image 422
La Carbonell Avatar asked Aug 27 '26 20:08

La Carbonell


1 Answers

Read the Javadoc:

defaultRegion - region that we are expecting the number to be from. This is only used if the number being parsed is not written in international format. The country_code for the number in this case would be stored as that of the default region supplied. If the number is guaranteed to start with a '+' followed by the country calling code, then "ZZ" or null can be supplied.

Your input is in international form, so this parameter is not used.

Why would you expect the library to convert a phone number in Belgium to one in Brazil?

like image 156
Andy Turner Avatar answered Aug 30 '26 10:08

Andy Turner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!