2

My JVM is running in US/Pacific Timezone but the client accesses the application from India;

for the first time Struts jQuery datepicker tag is loaded into browser with the default value of time as per JVM timezone.

I want it to be in clients timezone.

Can it be done in datepicker anyhow ?

<sj:datepicker theme="simple" 
                name="taskDate" 
               value="today"
          timepicker="true" 
    timepickerFormat="hh:mm:ss"
     buttonImageOnly="true" 
               style="width: 70px;"
               label="Task Date" 
                 key="taskDate" 
       displayFormat="ddMyy"  />

I've tried using Joda Time, but seems its not compatible with value in datepicker, when I use it loads blank value.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Ashish Verma
  • 762
  • 8
  • 14

1 Answers1

0

The date picker should not know about time zones, and simply use the time value you give it. Unless you of course include the time zone offset in the time specification you give it. toString() will by default include a timezone, so that will not work.

But this should:

<sj:datepicker theme="simple" 
                name="taskDate" 
               value="2015-05-26 11:00"
          timepicker="true" 
    timepickerFormat="hh:mm:ss"
     buttonImageOnly="true" 
               style="width: 70px;"
               label="Task Date" 
                 key="taskDate" 
       displayFormat="ddMyy"  />

To get a format without timezone, use something like:

%{new DateTime().strftime("%Y-%m-%d %H:%M")
Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
  • 1
    This doesn't solve my problem either. using `value="%{new java.util.Date()}"` or `value="%{new DateTime()}"` is like using `value="today"`. This again displays JVM time on first load & not the clients time. Please correct me if I didn't understand your answer & doing something worng. – Ashish Verma May 27 '15 at 02:42
  • @AshishVerma: The point of my answer is that you need to feed the widget a date time string that does NOT include the timezone. As per my example with `.strftime()`. Your examples WILL include the timezone. – Lennart Regebro May 27 '15 at 08:36