Browse Source

Update method phonenumberutil.format to return 'empty' instead of value '0'. (#3305)

pull/3309/head
mandlil 2 years ago
committed by GitHub
parent
commit
357f5bc2e1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions
  1. +2
    -4
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java

+ 2
- 4
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -1275,14 +1275,12 @@ public class PhoneNumberUtil {
* @return the formatted phone number
*/
public String format(PhoneNumber number, PhoneNumberFormat numberFormat) {
if (number.getNationalNumber() == 0 && number.hasRawInput()) {
if (number.getNationalNumber() == 0) {
// Unparseable numbers that kept their raw input just use that.
// This is the only case where a number can be formatted as E164 without a
// leading '+' symbol (but the original number wasn't parseable anyway).
// TODO: Consider removing the 'if' above so that unparseable
// strings without raw input format to the empty string instead of "+00".
String rawInput = number.getRawInput();
if (rawInput.length() > 0) {
if (rawInput.length() > 0 || !number.hasCountryCode()) {
return rawInput;
}
}


Loading…
Cancel
Save