You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2008/12/23 22:00:40 UTC
svn commit: r729110 -
/wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
Author: jdonnerstag
Date: Tue Dec 23 13:00:40 2008
New Revision: 729110
URL: http://svn.apache.org/viewvc?rev=729110&view=rev
Log:
wicket-1314 fixed: DateTimeField does not correct the timezone properly
Modified:
wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
Modified: wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java?rev=729110&r1=729109&r2=729110&view=diff
==============================================================================
--- wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java (original)
+++ wicket/trunk/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java Tue Dec 23 13:00:40 2008
@@ -45,10 +45,10 @@
import org.joda.time.format.DateTimeFormat;
/**
- * Works on a {@link java.util.Date} object. Displays a date field and a {@link DatePicker}, a field
- * for hours and a field for minutes, and an AM/PM field. The format (12h/24h) of the hours field
- * depends on the time format of this {@link DateTimeField}'s {@link Locale}, as does the visibility
- * of the AM/PM field (see {@link DateTimeField#use12HourFormat}).
+ * Works on a {@link java.util.Date} object. Displays a date field and a {@link DatePicker}, a
+ * field for hours and a field for minutes, and an AM/PM field. The format (12h/24h) of the hours
+ * field depends on the time format of this {@link DateTimeField}'s {@link Locale}, as does the
+ * visibility of the AM/PM field (see {@link DateTimeField#use12HourFormat}).
*
* @author eelcohillenius
* @see DateField for a variant with just the date field and date picker
@@ -321,8 +321,7 @@
TimeZone zone = getClientTimeZone();
if (zone != null)
{
- date.setMillis(DateTimeZone.getDefault().getMillisKeepLocal(
- DateTimeZone.forTimeZone(zone), date.getMillis()));
+ date.setMillis(getMillis(zone, TimeZone.getDefault(), date.getMillis()));
}
// the date will be in the server's timezone
@@ -340,6 +339,12 @@
}
}
+ private long getMillis(TimeZone to, TimeZone from, long instant)
+ {
+ return DateTimeZone.forTimeZone(from).getMillisKeepLocal(DateTimeZone.forTimeZone(to),
+ instant);
+ }
+
/**
* @deprecated replaced by {@link #newDateTextField(String, PropertyModel)}
*/
@@ -400,7 +405,7 @@
// instantiate with the previously set date
if (zone != null)
{
- date.setZone(DateTimeZone.forTimeZone(zone));
+ date.setMillis(getMillis(TimeZone.getDefault(), zone, date.getMillis()));
}
if (use12HourFormat)