assertEquals("000", phoneUtil.formatNumberForMobileDialing(auNumber, RegionCode.AU, false));
assertEquals("", phoneUtil.formatNumberForMobileDialing(auNumber, RegionCode.NZ, false));
}
public void testFormatByPattern() {
NumberFormat newNumFormat = new NumberFormat();
newNumFormat.setPattern("(\\d{3})(\\d{3})(\\d{4})");
newNumFormat.setFormat("($1) $2-$3");
List<NumberFormat> newNumberFormats = new ArrayList<NumberFormat>();
newNumberFormats.add(newNumFormat);
assertEquals("(650) 253-0000", phoneUtil.formatByPattern(US_NUMBER, PhoneNumberFormat.NATIONAL,
newNumberFormats));
assertEquals("+1 (650) 253-0000", phoneUtil.formatByPattern(US_NUMBER,
PhoneNumberFormat.INTERNATIONAL,
newNumberFormats));
assertEquals("tel:+1-650-253-0000", phoneUtil.formatByPattern(US_NUMBER,
PhoneNumberFormat.RFC3966,
newNumberFormats));
// $NP is set to '1' for the US. Here we check that for other NANPA countries the US rules are
// followed.
newNumFormat.setNationalPrefixFormattingRule("$NP ($FG)");
newNumFormat.setFormat("$1 $2-$3");
assertEquals("1 (242) 365-1234",
phoneUtil.formatByPattern(BS_NUMBER, PhoneNumberFormat.NATIONAL,
newNumberFormats));
assertEquals("+1 242 365-1234",
phoneUtil.formatByPattern(BS_NUMBER, PhoneNumberFormat.INTERNATIONAL,
newNumberFormats));
newNumFormat.setPattern("(\\d{2})(\\d{5})(\\d{3})");
newNumFormat.setFormat("$1-$2 $3");
newNumberFormats.set(0, newNumFormat);
assertEquals("02-36618 300",
phoneUtil.formatByPattern(IT_NUMBER, PhoneNumberFormat.NATIONAL,
newNumberFormats));
assertEquals("+39 02-36618 300",
phoneUtil.formatByPattern(IT_NUMBER, PhoneNumberFormat.INTERNATIONAL,
newNumberFormats));
newNumFormat.setNationalPrefixFormattingRule("$NP$FG");
newNumFormat.setPattern("(\\d{2})(\\d{4})(\\d{4})");
newNumFormat.setFormat("$1 $2 $3");
newNumberFormats.set(0, newNumFormat);
assertEquals("020 7031 3000",
phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL,
newNumberFormats));
newNumFormat.setNationalPrefixFormattingRule("($NP$FG)");
assertEquals("(020) 7031 3000",
phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL,
newNumberFormats));
newNumFormat.setNationalPrefixFormattingRule("");
assertEquals("20 7031 3000",
phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL,
newNumberFormats));
assertEquals("+44 20 7031 3000",