From 357f5bc2e12cf9b7371106215dcd9a2f6cae55fd Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:01:32 +0530 Subject: [PATCH] Update method phonenumberutil.format to return 'empty' instead of value '0'. (#3305) --- .../src/com/google/i18n/phonenumbers/PhoneNumberUtil.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 1f49d6747..c49189fa2 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -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; } }