You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org> on 2011/03/05 21:57:45 UTC
[jira] Issue Comment Edited: (WICKET-3510) DateTimeField improperly
converts time causing wrong dates when the server's current date is
different from the client's date.
[ https://issues.apache.org/jira/browse/WICKET-3510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13003044#comment-13003044 ]
Bertrand Guay-Paquet edited comment on WICKET-3510 at 3/5/11 8:55 PM:
----------------------------------------------------------------------
Sample output:
ERROR - DatePickerTest - =========== testDifferentDateTimeZoneConversion() =================
ERROR - DatePickerTest - orig: 1288951200000; date: 1288864800000; dateTime: 1288864800000
ERROR - DatePickerTest - orig: Thu Nov 04 22:00:00 GMT-12:00 2010; date: Wed Nov 03 22:00:00 GMT-12:00 2010; dateTime: Wed Nov 03 22:00:00 GMT-12:00 2010
As you can see, the hours are correct but the date is one day off.
was (Author: berniegp):
Sample output:
ERROR - DatePickerTest - =========== testDifferentDateTimeZoneConversion() =================
ERROR - DatePickerTest - orig: 1288951200000; date: 1288864800000; dateTime: 1288864800000
ERROR - DatePickerTest - orig: Thu Nov 04 22:00:00 GMT-12:00 2010; date: Wed Nov 03 22:00:00 GMT-12:00 2010; dateTime: Wed Nov 03 22:00:00 GMT-12:00 2010
> DateTimeField improperly converts time causing wrong dates when the server's current date is different from the client's date.
> ------------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-3510
> URL: https://issues.apache.org/jira/browse/WICKET-3510
> Project: Wicket
> Issue Type: Bug
> Components: wicket-datetime
> Affects Versions: 1.5-RC2
> Reporter: Bertrand Guay-Paquet
> Labels: datepicker, datetime
> Attachments: TestDateConverter.java
>
>
> The bug is in DateTimeField#convertInput().
> <code>
> // Get year, month and day ignoring any timezone of the Date object
> Calendar cal = Calendar.getInstance();
> cal.setTime(dateFieldInput);
> int year = cal.get(Calendar.YEAR);
> int month = cal.get(Calendar.MONTH) + 1;
> int day = cal.get(Calendar.DAY_OF_MONTH);
> int hours = (hoursInput == null ? 0 : hoursInput % 24);
> int minutes = (minutesInput == null ? 0 : minutesInput);
> // Use the input to create a date object with proper timezone
> MutableDateTime date = new MutableDateTime(year, month, day, hours, minutes, 0, 0,
> DateTimeZone.forTimeZone(getClientTimeZone()));
> </code>
> If the server's current date is different from the client's, this produces wrong output. I attached a patch with a test case that simulates this condition.
> I don't know why this "casting" of day, month, year is done.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira