@Test public void testExtractTimeZoneAndTestDate() throws Exception { HashMap<String, Boolean> testCases = new HashMap<>(); testCases.put("Feb 28" + FilterUtil.TIMEZONE_SEPARATOR + "+0000", true); testCases.put("Feb 27" + FilterUtil.TIMEZONE_SEPARATOR + "-0700", true); testCases.put("27, 2015" + FilterUtil.TIMEZONE_SEPARATOR + "+0700", false); testCases.put("14:24" + FilterUtil.TIMEZONE_SEPARATOR + "+1030", true); testCases.put("" + FilterUtil.TIMEZONE_SEPARATOR + "+1030", true); testCases.put("AM" + FilterUtil.TIMEZONE_SEPARATOR + "-0700", false); for (Map.Entry<String, Boolean> testCase : testCases.entrySet()) { Assert.assertEquals("Test case handled incorrectly: " + testCase.getKey(), testCase.getValue(), FilterUtil.extractTimeZoneAndTestDate(testCalendar.getTime(), testCase.getKey())); } }
public static boolean extractTimeZoneAndTestDate(Date date, String filter) { String[] timezoneAndFilter = extractTimeZone(filter); return StringUtils.containsIgnoreCase(formatDateTimeAsUI(convertDateToOffsetDateTime(date), timezoneAndFilter[1]), timezoneAndFilter[0]); }
FilterUtil { public static boolean extractTimeZoneAndTestDate(Date date, String filter) { String[] timezoneAndFilter = extractTimeZone(filter); return StringUtils.containsIgnoreCase(formatDateTimeAsUI(convertDateToOffsetDateTime(date), timezoneAndFilter[1]), timezoneAndFilter[0]); } }
FilterUtil { public static boolean extractTimeZoneAndTestDate(Date date, String filter) { String[] timezoneAndFilter = extractTimeZone(filter); return StringUtils.containsIgnoreCase(formatDateTimeAsUI(convertDateToOffsetDateTime(date), timezoneAndFilter[1]), timezoneAndFilter[0]); }  }
FilterUtil { public static boolean extractTimeZoneAndTestDate(Date date, String filter) { String[] timezoneAndFilter = extractTimeZone(filter); return StringUtils.containsIgnoreCase(formatDateTimeAsUI(convertDateToOffsetDateTime(date), timezoneAndFilter[1]), timezoneAndFilter[0]); }  static boolean extractTimeZoneAndTestDate(Date date, String filter); static OffsetDateTime convertDateToOffsetDateTime(Date date); static String[] extractTimeZone(String filter); static OffsetDateTime parseUIDate(String dateString, String timeZoneOffset); }
FilterUtil { public static boolean extractTimeZoneAndTestDate(Date date, String filter) { String[] timezoneAndFilter = extractTimeZone(filter); return StringUtils.containsIgnoreCase(formatDateTimeAsUI(convertDateToOffsetDateTime(date), timezoneAndFilter[1]), timezoneAndFilter[0]); }  static boolean extractTimeZoneAndTestDate(Date date, String filter); static OffsetDateTime convertDateToOffsetDateTime(Date date); static String[] extractTimeZone(String filter); static OffsetDateTime parseUIDate(String dateString, String timeZoneOffset);  }