Bug in the setTimestamp() method for Newfoundland time zone

From: Brent Eagles <brent(dot)eagles(at)iona(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Bug in the setTimestamp() method for Newfoundland time zone
Date: 2003-09-21 03:25:30
Message-ID: 20030921005530.B29156@ooc.nf.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

The Statement.setTimestamp() implementation has a bug in it for half
hour timezones west of GMT. Newfoundland is such a location with a
timezone offset of GMT -3:30. An example of a bogus string (calc
includes Daylight savings time offset) follows:

2003-07-15 10:43:35.000000-020-30

The problem is in here:

int l_minos = l_offset - (l_houros * 60);
if (l_minos != 0)
{
if (l_minos < 10)
sbuf.append('0');
sbuf.append(l_minos);
}

l_minos is going to be negative so 1. a zero is going to erroneously be
inserted into the stream and 2. the neg sign is going to be included in
sbuf.append(l_minos).

A possible fix is to modify the code like so:

if (l_minos != 0)
{
l_minos = Math.abs(l_minos);
if (l_minos < 10)
sbuf.append('0');
sbuf.append(l_minos);
}

Best regards,

Brent

--
Brent Eagles
Principal Engineer - IONA | Making Software Work Together TM
Email: mailto:brent(dot)eagles(at)iona(dot)com
Phone: (709) 738-3725 x18
WWW: http://www.iona.com/

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Angel Todorov 2003-09-21 15:43:22 JDBC with SSL
Previous Message Barry Lind 2003-09-20 19:14:04 Re: Stored Procedure returns a ResultSet