Subject setTimestamp with Calendar ignores daylight saving settings
Author ctrledge
Appolgies if this has been covered before but I couldn't find any
references when searching the list.

Before filling a bug report I thought it prudent to post it to this
list first.

When calling PreparedStatement.setTimestamp(int, TimeStamp, Calendar)
the corresponding value saved in the database is incorrect during
daylight savings.

In our case we are wanting to save all dates in UTC time. The code we
are using is
Date now = new Date();
Calendar utcCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
insertTran.setTimestamp(1, new Timestamp(now.getTime()), utcCal);

(the now = new Date() was just for the example)

Unfortunately the times being saved are one hour off UTC when compared
with 'date -u'.

I believe the problem is in the following code of XSQLVAR
public Timestamp encodeTimestamp(java.sql.Timestamp value, Calendar
cal, boolean invertTimeZone){
if (cal == null) {
return value;
}
else {
long time = value.getTime() +
(invertTimeZone ? -1 : 1) *
(cal.getTimeZone().getRawOffset() -
Calendar.getInstance().getTimeZone().getRawOffset());

return new Timestamp(time);
}

The use of getRawOffset() should be getOffset(value.getTime()) which
takes into account if the specified time is in a daylight savings period.

This with java 6 and jaybird 2.1.1

Regards

Ross