String startDayString = request.getParameter("DAY");
int startDay = Integer.parseInt(startDayString);
String startYearString = request.getParameter("YEAR");
int startYear = Integer.parseInt(startYearString);
Calendar start = new GregorianCalendar(startYear, startMonth, startDay, 8, 0);
String startTimeString = tf.format(start.getTime());
if (CVUtility.notEmpty(request.getParameter("STIME"))) {
startTimeString = request.getParameter("STIME");
}
Calendar passedTime = new GregorianCalendar();
passedTime.setTime(tf.parse(startTimeString));
start.set(Calendar.HOUR, passedTime.get(Calendar.HOUR));
start.set(Calendar.MINUTE, passedTime.get(Calendar.MINUTE));
start.set(Calendar.AM_PM, passedTime.get(Calendar.AM_PM));
activityForm.setActivityStartDate(df.format(start.getTime()));
activityForm.setActivityStartTime(tf.format(start.getTime()));
// add an hour onto the start time for the default end time.
Calendar end = new GregorianCalendar();
end.setTime(start.getTime());
end.add(Calendar.HOUR, 1);
String endTimeString = tf.format(end.getTime());
if (CVUtility.notEmpty(request.getParameter("ETIME"))) {
endTimeString = request.getParameter("ETIME");
}
passedTime.setTime(tf.parse(endTimeString));
end.set(Calendar.HOUR, passedTime.get(Calendar.HOUR));
end.set(Calendar.MINUTE, passedTime.get(Calendar.MINUTE));
end.set(Calendar.AM_PM, passedTime.get(Calendar.AM_PM));
activityForm.setActivityEndDate(df.format(end.getTime()));
activityForm.setActivityEndTime(tf.format(end.getTime()));
} else if (unScheduleActivity != null && !(unScheduleActivity.equals("unSchedule"))) {
// In the case the start time wasn't requested from the parent window,
// set the start time to now() rounded up to the nearest hour, and the
// end time to be the start time plus 1 hour.
UserPrefererences userPref = userObject.getUserPref();
String userTimeZoneId = userPref.getTimeZone();
TimeZone userTimeZone = TimeZone.getTimeZone(userTimeZoneId);
Calendar now = Calendar.getInstance(userTimeZone, locale);
// round up the hour if we are at the 1 minute mark of the hour or
// higher. just clear the second and millisecond fields, its only
// scheduling not physics.
now.clear(Calendar.SECOND);
now.clear(Calendar.MILLISECOND);
if (now.get(Calendar.MINUTE) > 0) {
now.clear(Calendar.MINUTE);
now.add(Calendar.HOUR, 1);
}
activityForm.setActivityStartDate(df.format(now.getTime()));
activityForm.setActivityStartTime(tf.format(now.getTime()));
// Increment now by 1 hour to get the end time.
now.add(Calendar.HOUR, 1);
activityForm.setActivityEndDate(df.format(now.getTime()));
activityForm.setActivityEndTime(tf.format(now.getTime()));
}
String typeOfActivity = "";
if (request.getParameter(ConstantKeys.TYPEOFACTIVITY) == null) {
typeOfActivity = ConstantKeys.APPOINTMENT;