java - com.google.i18n.phonenumbers 错误?

标签 java internationalization

据我所知,巴西国家代码是 +55

但是这段代码

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);

给我那个数字是有效的!

phoneNumber ----- > Country Code: 32 National Number: 495665962
isValid --------- > true
phoneNumberType - > MOBILE

最佳答案

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.

您输入的是国际格式,所以没有使用这个参数。

为什么您希望图书馆将比利时的电话号码转换为巴西的电话号码?

关于java - com.google.i18n.phonenumbers 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44309997/

相关文章:

java - 使用GUI设计器时如何在Intellij IDEA中设置当前区域设置?

ruby-on-rails - Rails 中的多种货币

java - 如何关联两个相等的子元素?

java - HTTPS Volley Invalid header 问题

java - If 语句不适用于两个 <Long> 列表 [Java]

javascript - 如何等待 Angular 模块加载?

java - 如何用Java构建短语语言翻译引擎

.net - C#中如何区分简体中文和繁体中文?

java - 结果集不会进入 while 循环并设置值

java - 如何扩展类java.security.SecureClassLoader?