IndexUtils { public static String serializeDateRange(Date startDate, Date endDate) { if (startDate == null) throw new IllegalArgumentException("Start date cannot be null"); if (endDate == null) throw new IllegalArgumentException("End date cannot be null"); StringBuffer buf = new StringBuffer("["); buf.append(dateFormat.format(startDate)); buf.append(" TO "); buf.append(dateFormat.format(endDate)); buf.append("]"); return buf.toString(); } private  IndexUtils(); static String clean(String q); static String serializeDate(Date date); static String serializeDateRange(Date startDate, Date endDate);  }
@Test public void testSerializeDateRange() { Calendar d = Calendar.getInstance(); d.set(Calendar.MILLISECOND, 0); d.set(Calendar.SECOND, 0); d.set(Calendar.MINUTE, 0); d.set(Calendar.HOUR_OF_DAY, 0); Date startDate = d.getTime(); d.add(Calendar.DAY_OF_MONTH, 2); d.set(Calendar.HOUR_OF_DAY, 5); d.set(Calendar.MINUTE, 59); Date endDate = d.getTime(); String serializedStartDate = df.format(startDate) + "T00:00:00Z"; String serializedEndDate = df.format(endDate) + "T05:59:00Z"; String day = "[" + serializedStartDate + " TO " + serializedEndDate + "]"; assertEquals(day, IndexUtils.serializeDateRange(startDate, endDate)); }