I'm trying to format a previously E164 formatted phone number into National format without the National Prefix number, I'm using PhoneNumberUtils to do it:
public static String getNationalPhone(String phoneE164Formatted) {
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
String phoneNumber = phoneE164Formatted;
try {
Phonenumber.PhoneNumber numberProto = phoneUtil.parseAndKeepRawInput(phoneE164Formatted, "");
phoneNumber = phoneUtil.format(numberProto, PhoneNumberUtil.PhoneNumberFormat.NATIONAL);
} catch (NumberParseException e) {
e.printStackTrace();
}
return phoneNumber;
}
With that code I'm getting the national prefix I don't want. For example, formatting this number "+526143342293" into national format gave me this result: "01 614 334 22 93", where "01" it's what I want to suppress.