cal.set(Calendar.HOUR, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
Term end = new Term("moment", DateField.dateToString(cal.getTime()));
query.add(new RangeQuery(begin, end, true), true, false);
}
catch (Exception e)
{
bean.addValidationError(new ValidationError.WRONGFORMAT("date"));
}
}
boolean beginDatePresent = (bean.getBeginDate() != null && !bean.getBeginDate().equals(""));
boolean endDatePresent = (bean.getEndDate() != null && !bean.getEndDate().equals(""));
if (beginDatePresent && endDatePresent)
{
String beginDateFormatted = null;
String endDateFormatted = null;
try
{
Date beginDateParsed = Search.INPUT_DATE_FORMAT_SHORT.parse(bean.getBeginDate());
Date endDateParsed = Search.INPUT_DATE_FORMAT_SHORT.parse(bean.getEndDate());
Calendar cal = Calendar.getInstance();
cal.setTime(endDateParsed);
cal.set(Calendar.HOUR, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
beginDateFormatted = DateField.dateToString(beginDateParsed);
endDateFormatted = DateField.dateToString(cal.getTime());
}
catch (ParseException e)
{
bean.addValidationError(new ValidationError.WRONGFORMAT("beginDate"));
bean.addValidationError(new ValidationError.WRONGFORMAT("endDate"));
}
if (bean.getValidationErrors().size() == 0)
{
Term begin = new Term("moment", beginDateFormatted);
Term end = new Term("moment", endDateFormatted);
query.add(new RangeQuery(begin, end, true), true, false);
}
}
else if (!beginDatePresent && !endDatePresent)
{
// noop; means they didn't try a date range