SolrUtils { public static String serializeDateRange(Option<Date> startDate, Option<Date> endDate) { final Function<Date, String> f = format(newSolrDateFormat()); return new StringBuilder("[") .append(startDate.map(f).getOrElse("*")) .append(" TO ") .append(endDate.map(f).getOrElse("*")) .append("]") .toString(); } private  SolrUtils(); static String clean(String q); static String serializeDate(Date date); static Date parseDate(String date); static String serializeDateRange(Option<Date> startDate, Option<Date> endDate); static DateFormat newSolrDateFormat();  }
@Test public void testSerializeDateRange() { Date startDate = newDate(1999, 3, 21, 14, 0, 0); Date endDate = newDate(1999, 3, 21, 14, 30, 10); String serializedStartDate = dateFormatUTC().format(startDate); String serializedEndDate = dateFormatUTC().format(endDate); String day = "[" + serializedStartDate + " TO " + serializedEndDate + "]"; assertEquals(day, SolrUtils.serializeDateRange(some(startDate), some(endDate))); assertEquals("[* TO " + serializedEndDate + "]", SolrUtils.serializeDateRange(Option.<Date>none(), some(endDate))); assertEquals("[" + serializedStartDate + " TO *]", SolrUtils.serializeDateRange(some(startDate), Option.<Date>none())); }