gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:03:29 27 4
gpt4 key购买 nike

据我所知,巴西国家代码是 +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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com