I am using the jquery timepicker plugin and it works fine. I can select a time and submit my form. I am using spring MVC 3.0 and the problem comes in when I attempt to parse a string ,which represents time, as a java carlendar.
I have been reading up on this date/time conversion, http://www.odi.ch/prog/design/datetime.php, and it seems quite complicated. Can someone please offer some form of advice. Here is my code, which is spring specific.
@RequestMapping(value = "scheduleadd", method = RequestMethod.POST)
public String scheduleadd( @Valid Schedule schedule, BindingResult bindingResult,
@RequestParam("startdate") @org.springframework.format.annotation.DateTimeFormat(iso=ISO.DATE) java.util.Calendar startdate,
@RequestParam("enddate") @org.springframework.format.annotation.DateTimeFormat(iso=ISO.DATE) java.util.Calendar enddate,
@RequestParam("starttime") @org.springframework.format.annotation.DateTimeFormat(iso=ISO.NONE) java.util.Calendar starttime,
@RequestParam("endtime") @org.springframework.format.annotation.DateTimeFormat(iso=ISO.NONE) java.util.Calendar endtime,
@RequestParam("moduleInstanceId") Long mId, Model uiModel, HttpServletRequest httpServletRequest) { //my stuff goes here}
As you can see, I am trying to parse a string like “09:30” as java Carlendar. Do I need the date part? How do I specify the date part ?
Use the
patternattribute of @DateTimeFormat to specify that the “time” fields are not fully-formed ISO datetimes, but rather just times; e.g.:And in your
scheduleadd()method, combine theCalendarfields to get a fully-formed datetime: