public void validate(final Form< ? > form)
{
final DateTimePanel startDateTimePanel = (DateTimePanel) dependentFormComponentsWithCost2[0];
final DropDownChoice<Integer> stopHourOfDayDropDownChoice = (DropDownChoice<Integer>) dependentFormComponentsWithCost2[1];
final DropDownChoice<Integer> stopMinuteDropDownChoice = (DropDownChoice<Integer>) dependentFormComponentsWithCost2[2];
final DateHolder startDate = new DateHolder(startDateTimePanel.getConvertedInput());
final DateHolder stopDate = new DateHolder(startDate.getTimestamp());
stopDate.setHourOfDay(stopHourOfDayDropDownChoice.getConvertedInput());
stopDate.setMinute(stopMinuteDropDownChoice.getConvertedInput());
if (stopDate.getTimeOfDay() < startDate.getTimeOfDay()) { // Stop time is
// before start time. Assuming next day for stop time:
stopDate.add(Calendar.DAY_OF_MONTH, 1);
}
data.setStartTime(startDate.getTimestamp());
data.setStopTime(stopDate.getTimestamp());
if (data.getDuration() < 60000) {
// Duration is less than 60 seconds.
stopMinuteDropDownChoice.error(getString("timesheet.error.zeroDuration"));
} else if (data.getDuration() > TimesheetDao.MAXIMUM_DURATION) {
stopMinuteDropDownChoice.error(getString("timesheet.error.maximumDurationExceeded"));