Skip to Content.
Sympa Menu

freetds - Re: JDBC: timezone difference except with getdate()

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: brlewis AT alum.mit.edu
  • To: <freetds AT franklin.oit.unc.edu>
  • Subject: Re: JDBC: timezone difference except with getdate()
  • Date: Wed, 27 Oct 1999 12:27:55 -0400


I got the behavior I wanted with the patch below.

The patch also adds comments that draw attention to an issue that may
come up if SYBDATETIMN is returned for something besides getdate().


--- Tds.java 1999/10/27 12:53:52 1.1
+++ Tds.java 1999/10/27 15:56:05
@@ -1511,9 +1511,12 @@
int len;
Object result;
int offset; // offset between local time and GMT in seconds
+ boolean zoneless = false; // true means received type has no TZ

if (type == SYBDATETIMN)
{
+ // FIXME: Offset should vary with DST.
+ // Works now because this type is only used for getdate().
offset = (new java.util.Date()).getTimezoneOffset() * 60;
len = comm.getByte();
}
@@ -1522,6 +1525,12 @@
offset = 0;
len = 4;
}
+ else if (type == SYBDATETIME)
+ {
+ offset = 0;
+ len = 8;
+ zoneless = true;
+ }
else
{
offset = 0;
@@ -1547,8 +1556,12 @@
long micros = ((time % 300) * 1000000) / 300;
long millis = (micros / 1000)
+ ((micros % 1000)>=500 ? 1 : 0);
-
- result = new Timestamp((seconds+offset) * 1000 + millis);
+ long result_date = (seconds+offset) * 1000 + millis;
+
+ if (zoneless)
+ result_date = Date.parse(((new
Timestamp(result_date)).toGMTString()).substring(0, 20)) + millis;
+
+ result = new Timestamp(result_date);
break;
}
case 4:




Archive powered by MHonArc 2.6.24.

Top of Page