Hello,

We have a problem using the <s:datepicker> tag when it comes to modifying a
date and time.
It seems there is no solution in struts2 to edit a date + time with the
datepicker tag, so we use them separately.

In our Action class we have a attribute called "currentTimePart":

private Date currentDatePart;
private Date currentTimePart;
(getter and setter are available).

In our Action method we use the following code :

public String modify() throws Exception {
       log.debug("view method called");

       Date now = new Date();
       this.setCurrentDatePart(now);
       Calendar cal = Calendar.getInstance();
       cal.setTime(now);
       cal.set(Calendar.HOUR, 10);
       cal.set(Calendar.MINUTE, 15);
       this.setCurrentTimePart(cal.getTime());

       return SUCCESS;
   }

As you can see, the current date is set in a Calendar instance.
The HOUR and MINUTE are overriden and the currentTimePart is set.

We use the following tag in the JSP page:
<s:datetimepicker name="currentDatePart" displayFormat="dd-MM-yyyy"
theme="simple" />
<br />
<s:datetimepicker name="currentTimePart" displayFormat="HH:mm"
theme="simple" type="time"/>
(Notice the type="time" attribute.)

The page successfully shows a datePicker with the correct value, but the
timePicker shows the value "00:00".

It seems that the DateTimePicker component, in struts2 or dojo framework,
does not handle the time part of the given Date object correctly.

Can anyone help us out?

Thank you!

Greetz
Kishen (and co-workers)

Reply via email to