Related to
JtdsPreparedStatement setTime setTimestamp Daylight DST Bug - ID: 1176221
https://sourceforge.net/tracker/index.php?func=detail&aid=1176221&group_id=
33291&atid=407762
Some background:
1. Our application stores all our dates in GMT. Hence when we insert
dates using a PreparedStatement we use the method public void
setTimestamp(int parameterIndex, Timestamp x, Calendar cal) method passing
in a Calendar.getInstance(TimeZone.getTimeZone("GMT"))
2. We are based in Sydney, Australia and hence our test instances have a
default TimeZone of Australian Eastern Standard Time (AEST)
3. Daylight saving started in Sydney on the 4th October 2009 0200 (AEST)
or equivalently in GMT 3rd October 2009 1600 (GMT)
The problem:
We had tests set up to test whether the date/times inserted into a SQL
Server 2005 over this daylight saving changeover period were correct. We
found they were correct except for a 1 hour block between 4th October 2009
1300-1400 (AEST) or 4th October 0200-0300 (GMT). These were always stored
one hour ahead.
I had a look at the source code, I think the problem lies in the method
Support.timeFromZone(java.util.Date value, Calendar target)After reading
through this thread, I gather the purpose of this method was to convert the
Date object value to a UTC long. This long will have the equivalent 'wall'
time in the local time zone as value has in the time zone stored in the
Calendar object target.
Problems arise when the 'wall' time contains values that cannot be
represented in the local timezone. In our example, since daylight saving in
Sydney begins at 4th October 2009 0200 (clocks shift forward one hour to
0300), the period from 0200-0300 does not a valid date/time for the
timezone AEST. Hence when Support.timeFromZone encounters dates that have a
wall time that lie in this period (i.e. 4th October 0200-0300 (GMT)) , the
static Calendar object Support.cal shifts the hour-of-day field 1 hour
forward resulting in all dates in this period being stored in the database
1 hour forward.
Attached is a JUnit test case that fails on v 1.2.4
See discussion at
https://sourceforge.net/projects/jtds/forums/forum/129584/topic/1260179/ind
ex/page/1
momo
Date/time handling
None
Public
|
Date: 2009-11-06 06:53 I just came across patch ID 2731952 |
|
Date: 2009-11-05 14:13 Proposed solution: |
| Filename | Description | Download |
|---|---|---|
| TimeZone2Test.java | JUnit test case | Download |
| Field | Old Value | Date | By |
|---|---|---|---|
| assigned_to | alin_sinpalean | 2009-11-06 06:53 | grimlock81 |
| File Added | 348480: TimeZone2Test.java | 2009-10-28 03:18 | grimlock81 |
Copyright © 2009 Geeknet, Inc. All rights reserved. Terms of Use