// Start date text field selected
if (event.getRelativeElement() == dateTo.getElement()) {
dateTo.setStyleName(CLASSNAME_DATEFIELD);
DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy");
Date end = format.parse(dateTo.getText());
DateTimeFormat formatter = DateTimeFormat.getFormat("MMM d, y");
if (end.compareTo(getEndDate()) <= 0
&& end.compareTo(intervalStartDate) > 0) {
dateTo.setText(formatter.format(end));
intervalEndDate = end;
setBrowserRange(intervalStartDate, intervalEndDate);
setDisplayRange(intervalStartDate, intervalEndDate, true);
} else {
dateTo.setText(formatter.format(intervalEndDate));
}
// End date textfield selected
} else if (event.getRelativeElement() == dateFrom.getElement()) {
dateFrom.setStyleName(CLASSNAME_DATEFIELD);
DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy");
Date start = format.parse(dateFrom.getText());
DateTimeFormat formatter = DateTimeFormat.getFormat("MMM d, y");
if (start.compareTo(getStartDate()) >= 0
&& start.compareTo(intervalEndDate) < 0) {
dateFrom.setText(formatter.format(start));
intervalStartDate = start;
setBrowserRange(intervalStartDate, intervalEndDate);
setDisplayRange(intervalStartDate, intervalEndDate, true);
} else {
dateFrom.setText(formatter.format(intervalStartDate));
}
}
}