@Test public void testCheckDateRangeSearch() throws Exception { assertNull(ComplexSearchUtils.checkDateRangeSearch("a")); assertNull(ComplexSearchUtils.checkDateRangeSearch("today")); assertNull(ComplexSearchUtils.checkDateRangeSearch("1982")); assertNull(ComplexSearchUtils.checkDateRangeSearch("1982099766<")); assertNull(ComplexSearchUtils.checkDateRangeSearch("<1982099766")); assertNull(ComplexSearchUtils.checkDateRangeSearch("1982a<")); assertNull(ComplexSearchUtils.checkDateRangeSearch("1982-SEP<")); assertNull(ComplexSearchUtils.checkDateRangeSearch("<1982-SEP")); Pair<LocalDateTime, LocalDateTime> search; search = ComplexSearchUtils.checkDateRangeSearch("1982<"); assertNotNull(search); assertEquals("1982-01-01 00:00:00", DateUtils.formatSDT(search.getFirst())); assertNull(search.getSecond()); search = ComplexSearchUtils.checkDateRangeSearch("1982-09<"); assertNotNull(search); assertEquals("1982-09-01 00:00:00", DateUtils.formatSDT(search.getFirst())); assertNull(search.getSecond()); search = ComplexSearchUtils.checkDateRangeSearch("1982-09-28<"); assertNotNull(search); assertEquals("1982-09-28 00:00:00", DateUtils.formatSDT(search.getFirst())); assertNull(search.getSecond()); search = ComplexSearchUtils.checkDateRangeSearch("1982-09-31<"); assertNotNull(search); assertEquals("1982-09-30 00:00:00", DateUtils.formatSDT(search.getFirst())); assertNull(search.getSecond()); search = ComplexSearchUtils.checkDateRangeSearch("<1982"); assertNotNull(search); assertNull(search.getFirst()); assertEquals("1982-01-01 00:00:00", DateUtils.formatSDT(search.getSecond())); search = ComplexSearchUtils.checkDateRangeSearch("<1982-09"); assertNotNull(search); assertNull(search.getFirst()); assertEquals("1982-09-01 00:00:00", DateUtils.formatSDT(search.getSecond())); search = ComplexSearchUtils.checkDateRangeSearch("<1982-09-28"); assertNotNull(search); assertNull(search.getFirst()); assertEquals("1982-09-28 00:00:00", DateUtils.formatSDT(search.getSecond())); search = ComplexSearchUtils.checkDateRangeSearch("<1982-09-31"); assertNotNull(search); assertNull(search.getFirst()); assertEquals("1982-09-30 00:00:00", DateUtils.formatSDT(search.getSecond())); search = ComplexSearchUtils.checkDateRangeSearch("1982-09<2017-03-12"); assertNotNull(search); assertEquals("1982-09-01 00:00:00", DateUtils.formatSDT(search.getFirst())); assertEquals("2017-03-12 00:00:00", DateUtils.formatSDT(search.getSecond())); search = ComplexSearchUtils.checkDateRangeSearch("1982-09 < 2017-03-12"); assertNotNull(search); assertEquals("1982-09-01 00:00:00", DateUtils.formatSDT(search.getFirst())); assertEquals("2017-03-12 00:00:00", DateUtils.formatSDT(search.getSecond())); }
public static Pair<LocalDateTime, LocalDateTime> checkDateRangeSearch(String filter) { if (filter.length() > 4 && filter.contains("<")) { final String[] fromAndTo = org.apache.commons.lang.StringUtils.splitPreserveAllTokens(filter, '<'); final LocalDateTime from = fromAndTo.length > 0 ? stringToDate(fromAndTo[0].trim()) : null; final LocalDateTime to = fromAndTo.length > 1 ? stringToDate(fromAndTo[1].trim()) : null; if (from != null || to != null) { return new Pair<>(from, to); } } return null; }
ComplexSearchUtils { public static Pair<LocalDateTime, LocalDateTime> checkDateRangeSearch(String filter) { if (filter.length() > 4 && filter.contains("<")) { final String[] fromAndTo = org.apache.commons.lang.StringUtils.splitPreserveAllTokens(filter, '<'); final LocalDateTime from = fromAndTo.length > 0 ? stringToDate(fromAndTo[0].trim()) : null; final LocalDateTime to = fromAndTo.length > 1 ? stringToDate(fromAndTo[1].trim()) : null; if (from != null || to != null) { return new Pair<>(from, to); } } return null; } }
ComplexSearchUtils { public static Pair<LocalDateTime, LocalDateTime> checkDateRangeSearch(String filter) { if (filter.length() > 4 && filter.contains("<")) { final String[] fromAndTo = org.apache.commons.lang.StringUtils.splitPreserveAllTokens(filter, '<'); final LocalDateTime from = fromAndTo.length > 0 ? stringToDate(fromAndTo[0].trim()) : null; final LocalDateTime to = fromAndTo.length > 1 ? stringToDate(fromAndTo[1].trim()) : null; if (from != null || to != null) { return new Pair<>(from, to); } } return null; } private  ComplexSearchUtils(); }
ComplexSearchUtils { public static Pair<LocalDateTime, LocalDateTime> checkDateRangeSearch(String filter) { if (filter.length() > 4 && filter.contains("<")) { final String[] fromAndTo = org.apache.commons.lang.StringUtils.splitPreserveAllTokens(filter, '<'); final LocalDateTime from = fromAndTo.length > 0 ? stringToDate(fromAndTo[0].trim()) : null; final LocalDateTime to = fromAndTo.length > 1 ? stringToDate(fromAndTo[1].trim()) : null; if (from != null || to != null) { return new Pair<>(from, to); } } return null; } private  ComplexSearchUtils(); static Pair<String, String> checkSpecialSearch(String filter, char[] binarySortedPrefixes); static Pair<String, BigDecimal> checkNumericSearch(String filter, char[] binarySortedPrefixes, int precision); static Pair<LocalDateTime, LocalDateTime> checkDateRangeSearch(String filter); }
ComplexSearchUtils { public static Pair<LocalDateTime, LocalDateTime> checkDateRangeSearch(String filter) { if (filter.length() > 4 && filter.contains("<")) { final String[] fromAndTo = org.apache.commons.lang.StringUtils.splitPreserveAllTokens(filter, '<'); final LocalDateTime from = fromAndTo.length > 0 ? stringToDate(fromAndTo[0].trim()) : null; final LocalDateTime to = fromAndTo.length > 1 ? stringToDate(fromAndTo[1].trim()) : null; if (from != null || to != null) { return new Pair<>(from, to); } } return null; } private  ComplexSearchUtils(); static Pair<String, String> checkSpecialSearch(String filter, char[] binarySortedPrefixes); static Pair<String, BigDecimal> checkNumericSearch(String filter, char[] binarySortedPrefixes, int precision); static Pair<LocalDateTime, LocalDateTime> checkDateRangeSearch(String filter);  }