将国际电话号码转换为本地电话号码
我正在尝试使用 libphonenumber
google 库来转换数字 国际到本地。
国际号码代表为:“+97239658320”
本地号码(以色列为):“039658320”
http://code.google.com/p/libphonenumber/
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
PhoneNumber phone = null;
try
{
phone = PhoneNumberUtil.getInstance().parse("+97239658320", null);
}
catch (NumberParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
但是,在“phone”中,结果是:
Country Code: 972 National Number: 39658320 (without the leading zero)
如何正确转换它?
I'm trying to use libphonenumber
google library to convert a number from
international to local.
The international number represent is: "+97239658320"
The local number (here in Israel is): "039658320"
http://code.google.com/p/libphonenumber/
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
PhoneNumber phone = null;
try
{
phone = PhoneNumberUtil.getInstance().parse("+97239658320", null);
}
catch (NumberParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
however, in "phone" the results are:
Country Code: 972 National Number: 39658320 (without the leading zero)
how do I convert it correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 项目页面 的快速示例表明,解析后您应该具有:
获取它按照您想要的格式,您应该使用
NATIONAL
格式对其进行格式化:要删除任何电话号码分隔符,请查看 stripSeparators() 来自 android.telephony.PhoneNumberUtils
Looking at the quick example of the project page says that you after parsing should have:
To get it in your desired format you should format it with format
NATIONAL
:To strip out any phone number separators take a look at stripSeparators() from android.telephony.PhoneNumberUtils