You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ryan LaHue <ry...@gmail.com> on 2009/04/29 22:08:39 UTC

Weird DatePicker / DateTextField off by one hour

I have a DateTextField to which I am adding a DatePicker.  The Display works
fine: if I select 4/1/2009 using the DatePicker and I save the form data to
my database, then populate the form again from values in the database, I am
seeing 4/1/2009.

But when I look at my database I see that the stored date is actually
3/31/2009 23:00:00, which is 1 hour before 4/1/2009.

This does not seem to be a Locale issue (that I can tell), as I am running
everything on my local machine.  Also, the odd thing is that when I select
4/1/2009 through 4/5/2009 I get a date stored in my database which is 1 hour
before the selected date.  But when I select anything from 4/6/2009 through
4/30/2009 the date is stored correctly.

I added log statements when the info is loaded from the database and before
it is persisted, and the issue is within the web application.  When I print
the dates before persisting them to the database they are wrong by 1 hour,
for 4/1/2009 through 4/5/2009.

I had the same issue with yui.DateField, but I'm not sure if this is a YUI
DatePicker issue or something else I am not considering or doing correctly.

Here's a snippet of my code:

    DateTextField appointmentPickerTextField = new
DateTextField("dayOfYear", new PropertyModel(appointment, "dayOfYear"), new
StyleDateConverter(false)) {
      @Override
      public boolean isVisible() {
        return appointment.getScheduledDate() != null;
      }
    };
    appointmentPickerTextField .setRequired(true);
    appointmentPickerTextField .add(new DatePicker());

Any thoughts?

Re: Weird DatePicker / DateTextField off by one hour

Posted by Ryan Gravener <ry...@ryangravener.com>.
https://issues.apache.org/jira/browse/WICKET-1314

Ryan Gravener
http://isithotinhereorisitjust.me | http://twitter.com/ryangravener


On Thu, Apr 30, 2009 at 11:28 AM, Ryan Gravener <ry...@ryangravener.com>wrote:

> What version of wicket, what timezone?
>

Re: Weird DatePicker / DateTextField off by one hour

Posted by Ryan Gravener <ry...@ryangravener.com>.
What version of wicket, what timezone?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Weird DatePicker / DateTextField off by one hour

Posted by mallet <ry...@gmail.com>.
I'm using 1.4 RC2.  It was a daylight savings time issue... but one in my
IDE's JRE rather than in Wicket.  I patched it up and things are behaving as
expected now.  Thanks for the additional info about the timezone issue.
-- 
View this message in context: http://www.nabble.com/Weird-DatePicker---DateTextField-off-by-one-hour-tp23304596p23369989.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Weird DatePicker / DateTextField off by one hour

Posted by Stephan Koch <sk...@remove-n0spam.sk-dev.com>.
Hi Ryan,

this should be a timezone issue. The date is timezone sensitive, so take
a look at java.util.TimeZone and especially at what timezone your
datepicker / datefield is set to use. You might have to override that.
Have a look to the Timezone of the Date object in your debugger before
persisting to DB, and afterwards.

I bet there's a TZ conversion happening somwhere that subtracts that one
hour you are missing. Also check for Daylight Savings time, that might
explain why it only happens with certain dates.

BR,
Stephan

Ryan LaHue wrote:
> I have a DateTextField to which I am adding a DatePicker.  The Display works
> fine: if I select 4/1/2009 using the DatePicker and I save the form data to
> my database, then populate the form again from values in the database, I am
> seeing 4/1/2009.
>
> But when I look at my database I see that the stored date is actually
> 3/31/2009 23:00:00, which is 1 hour before 4/1/2009.
>
> This does not seem to be a Locale issue (that I can tell), as I am running
> everything on my local machine.  Also, the odd thing is that when I select
> 4/1/2009 through 4/5/2009 I get a date stored in my database which is 1 hour
> before the selected date.  But when I select anything from 4/6/2009 through
> 4/30/2009 the date is stored correctly.
>
> I added log statements when the info is loaded from the database and before
> it is persisted, and the issue is within the web application.  When I print
> the dates before persisting them to the database they are wrong by 1 hour,
> for 4/1/2009 through 4/5/2009.
>
> I had the same issue with yui.DateField, but I'm not sure if this is a YUI
> DatePicker issue or something else I am not considering or doing correctly.
>
> Here's a snippet of my code:
>
>     DateTextField appointmentPickerTextField = new
> DateTextField("dayOfYear", new PropertyModel(appointment, "dayOfYear"), new
> StyleDateConverter(false)) {
>       @Override
>       public boolean isVisible() {
>         return appointment.getScheduledDate() != null;
>       }
>     };
>     appointmentPickerTextField .setRequired(true);
>     appointmentPickerTextField .add(new DatePicker());
>
> Any thoughts?
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org