int day = cal.get(Calendar.DAY_OF_MONTH);
int hours = (hoursInput == null ? 0 : hoursInput % 24);
int minutes = (minutesInput == null ? 0 : minutesInput);
// Use the input to create a date object with proper timezone
MutableDateTime date = new MutableDateTime(year, month, day, hours, minutes, 0, 0,
DateTimeZone.forTimeZone(getClientTimeZone()));
// Adjust for halfday if needed
if (use12HourFormat())
{
int halfday = (amOrPmInput == AM_PM.PM ? 1 : 0);
date.set(DateTimeFieldType.halfdayOfDay(), halfday);
date.set(DateTimeFieldType.hourOfHalfday(), hours % 12);
}
// The date will be in the server's timezone
setConvertedInput(newDateInstance(date.getMillis()));
}
catch (RuntimeException e)
{
DateTimeField.this.error(e.getMessage());
invalid();