db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller" <thomas.tom.muel...@gmail.com>
Subject Date 2042-10-12 problem using Brasilia time zone
Date Fri, 31 Oct 2008 14:20:51 GMT

I am implementing the Java database engine H2 (www.h2database.com - a
competitor of Apache Derby and HSQLDB).

I user of my database in Brasil recently found a problem with the date
2042-10-12. In Brasil, at that day, the time 00:00:00 (midnight)
doesn't 'exist' because it is the end of the daylight saving time. It
looks like this is a problem of java.sql.Date:

> 2042-10-11

This happens when using the timezone Brasilia. I tried with JDK
1.6.0_05 but I guess that happens on all version of Java. I use
Windows XP but again I don't think this is the problem. I also noticed
for Apache Derby and HSQLDB:

create table test(d date);
insert into test values('2042-10-12');
select d, cast(d as varchar(255)) from test;
> 2042-10-11 2042-10-11
drop table test;

I think that Java sets the time to 11:00:00 of the previous day. That
might be technically correct, but I hope you agree it's a problem.

What I plan to do in my database engine is to set the time to 12:00:00
(midday). Unfortunately this breaks a few things, like equality of
java.sql.Date that are returned by H2 and dates that are created by
java.sql.Date.valueOf, but I don't know how to solve the problem
otherwise (short term). Long term, an option might be to fix the
problem in java.sql.Date.

I hope that we Java database implementors (Apache Derby, HSQLDB, H2)
find a common solution to that problem. I also wrote this message to
HSQLDB at  http://sourceforge.net/forum/message.php?msg_id=5548088

What do you think would be the best solution?


View raw message