How to format a phone numbers with libphonenumber in International format.

前端 未结 2 568
面向向阳花
面向向阳花 2021-02-13 21:15

In the documentation provided by libphonenumber on Github, there is a demo, which converts any provided number into International Format, e.g +4915213116250 is conv

2条回答
  •  旧时难觅i
    2021-02-13 21:49

    Have you tried this?

    var phoneUtil = PhoneNumberUtil.GetInstance();
    var numberProto = phoneUtil.Parse("1234567890", "IT");
    var formattedPhone = phoneUtil.Format(numberProto, PhoneNumberFormat.INTERNATIONAL);
    

    This will give you "+39 123 456 7890"

提交回复
热议问题