Listing all country codes of phone numbers

2019-03-17 15:11发布

I'd like to have the country code list for phone numbers. Such as, United State (+1), United Kingdom (+44) ... I know that libphonenumber is a great tool to help phone parsing, formatting and validation. However, it doesn't seem to have the functionality for listing all country codes. But those data should be within the metadata in libphonenumber, right? Does anyone have experience on this?

7条回答
smile是对你的礼貌
2楼-- · 2019-03-17 15:52

I have use libphonenumber in one of my project. For that we have list of country codes.

public static int findCountryCode(String countryShortCode) {

    PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
    return phoneUtil.getCountryCodeForRegion(countryShortCode.toUpperCase());

}
查看更多
登录 后发表回答