PhoneNumberHandlerBase { public static List<String> getTimeZonesForNumber(Object data, String regionCode) { return getTimeZonesForNumber(parseToPhoneNumber(data, regionCode)); }  static PhoneNumber parseToPhoneNumber(Object data, String regionCode); static boolean isValidPhoneNumber(Object data, String regionCode); static boolean isPossiblePhoneNumber(Object data, String regionCode); static String formatE164(Object data, String regionCode); static String formatInternational(Object data, String regionCode); static String formatNational(Object data, String regionCode); static String formatRFC396(Object data, String regionCode); static Set<String> getSupportedRegions(); static int getCountryCodeForRegion(String regionCode); static int getCountryCodeForPhoneNumber(PhoneNumber number); static PhoneNumberTypeEnum getPhoneNumberType(Object data, String regionCode); static PhoneNumberTypeEnum getPhoneNumberType(PhoneNumber number); static boolean containsValidRegionCode(Object data); static String extractRegionCode(Object phoneData); static String extractRegionCode(Object phoneData, String regionCode); static String extractRegionCode(PhoneNumber phoneNumber); static int extractCountrycode(Object phoneData); static String getGeocoderDescriptionForNumber(Object data, String regionCode, Locale languageCode); static String getGeocoderDescriptionForNumber(PhoneNumber number, Locale languageCode); static String getCarrierNameForNumber(Object data, String regionCode, Locale languageCode); static String getCarrierNameForNumber(PhoneNumber number, Locale languageCode); static List<String> getTimeZonesForNumber(Object data, String regionCode); static List<String> getTimeZonesForNumber(PhoneNumber number); static List<String> getTimeZonesForNumber(Object data, String regionCode, boolean withUnknownTimeZone); static List<String> getTimeZonesForNumber(PhoneNumber phoneNumber, boolean withUnknownTimeZone);  }
@Test public void testGetTimeZonesForNumber() { assertEquals(PhoneNumberToTimeZonesMapper.getUnknownTimeZone(), PhoneNumberHandlerBase.getTimeZonesForNumber(null, null).get(0)); assertEquals(1, PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_1, REGCODE_CN).size()); assertEquals("[Asia/Shanghai]", PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_1, REGCODE_CN).toString()); assertEquals("[Asia/Shanghai]", PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_2, REGCODE_CN).toString()); assertEquals("[Asia/Shanghai]", PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_4, REGCODE_CN).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_1, REGCODE_JP).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_2, REGCODE_JP).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_3, REGCODE_JP).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_4, REGCODE_JP).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_5, REGCODE_JP).toString()); assertEquals(1, PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_1, REGCODE_FR).size()); assertEquals("[Europe/Paris]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_1, REGCODE_FR).toString()); assertEquals("[Europe/Paris]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_2, REGCODE_FR).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_3, REGCODE_FR).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_4, REGCODE_FR).toString()); assertEquals("[Europe/Paris]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_5, REGCODE_FR).toString()); assertEquals("[America/Los_Angeles]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_1, REGCODE_US).toString()); assertEquals("[America/Los_Angeles]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_2, REGCODE_US).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_3, REGCODE_US).toString()); assertEquals("[America/Los_Angeles]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_4, REGCODE_US).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_5, REGCODE_US).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_6, REGCODE_US).toString()); assertEquals("[Europe/Berlin]", PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_1, REGCODE_US).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_2, REGCODE_US).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_3, REGCODE_US).toString()); assertEquals("[Etc/Unknown]", PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_4, REGCODE_US).toString()); }
@Test public void testGetTimeZonesForNumberWithoutUnknown() { assertEquals(1, PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_1, REGCODE_CN, false).size()); assertEquals("[Asia/Shanghai]", PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_1, REGCODE_CN, false).toString()); assertEquals("[Asia/Shanghai]", PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_2, REGCODE_CN, false).toString()); assertEquals("[Asia/Shanghai]", PhoneNumberHandlerBase.getTimeZonesForNumber(CN_NUM_4, REGCODE_CN, false).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_1, REGCODE_JP, false).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_2, REGCODE_JP, false).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_3, REGCODE_JP, false).toString()); assertEquals("[Asia/Tokyo]", PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_4, REGCODE_JP, false).toString()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(JP_NUM_5, REGCODE_JP, false).size()); assertEquals(1, PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_1, REGCODE_FR, false).size()); assertEquals("[Europe/Paris]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_1, REGCODE_FR, false).toString()); assertEquals("[Europe/Paris]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_2, REGCODE_FR, false).toString()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_3, REGCODE_FR, false).size()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_4, REGCODE_FR, false).size()); assertEquals("[Europe/Paris]", PhoneNumberHandlerBase.getTimeZonesForNumber(FR_NUM_5, REGCODE_FR, false).toString()); assertEquals("[America/Los_Angeles]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_1, REGCODE_US, false).toString()); assertEquals("[America/Los_Angeles]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_2, REGCODE_US, false).toString()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_3, REGCODE_US, false).size()); assertEquals("[America/Los_Angeles]", PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_4, REGCODE_US, false).toString()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_5, REGCODE_US, false).size()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(US_NUM_6, REGCODE_US, false).size()); assertEquals("[Europe/Berlin]", PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_1, REGCODE_US, false).toString()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_2, REGCODE_US, false).size()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_3, REGCODE_US, false).size()); assertEquals(0, PhoneNumberHandlerBase.getTimeZonesForNumber(DE_NUM_4, REGCODE_US, false).size()); }