Submitted On 17-JUN-2002
gcristof
I'm experiencing a similar problem on JDK 1.4. I set a new
Timestamp using a long GMT millis value (1035694800000). I
store it in a database in a datetime field. I immediately
perform a SELECT and retrieve the value back into a new
Timestamp object. getTime() now returns 1035698400000
which is one hour later. I've tried this with Oracle,
Informix, and MySql, all with the same results. If I turn
off "Automatically adjust clock for daylight savings time"
in Windows, I now get the correct date and time back.
Submitted On 11-OCT-2002
alster
Similiarly, on Windows XP, jdk1.4.1: - the time is off by one
hour when "Automatically adjust clock for daylight savings" is
off. (Which is the default with dell box's, I believe)
System.out.println(new Date(System.currentTimeMillis
()).toString());
Submitted On 11-NOV-2002
sflasby
I am experiencing a similar problem to gcristof, but I'm using VAJ which is 1.2 compliant.
There seem to be two issues here:
1. java.sql.Timestamp uses different rules for reading a timestamp from and writing a timestamp to a DB.
2. an absolute milliseconds value is being interpreted as a local time and not an absolute time.
I need an absolute time to be written to the DB. In particular, when I write new Timestamp(0) into the DB, I expect to see 1/1/1970 00:00:00 not something with Daylight saving or local timezone deltas applied.
Steve Flasby
Submitted On 11-AUG-2003
locash626
I am also having the similar issue with the timestamp, I have
been unable to come up with a suitable work around.
Submitted On 11-AUG-2003
jmh31
I'm having the same problem with JDK 1.4.2. It only happens
when a timestamp gets serialized between two windows
machines (XP SP1 in my case) and one has automatically
adjust for GMT set and the other one doesn't. This is a
really serious problem for us since we pass timestamps back
to our Swing GUI client which then reports all the dates as
-1 hour.
Submitted On 24-OCT-2008
tyg08
Has the bug been resolved in the later relase of jdk? And so, which jdk version is it?
Otherwise, what's the plan on the bug resolution from sun?
Submitted On 18-NOV-2008
mthornton
The bug here is in ever applying daylight time corrections to GMT. However that misnaming of the UK civil timezone is an historic mistake in Java and unlikely to be corrected for compatibility reasons.
The surprising behaviour and apparent regression stems from two features:
First, starting with 1.4, Java implemented historically correct timezone offsets.
Secondly, between 1968 and 1971 the UK operated on British Standard Time, which was 1 hour ahead of GMT (UTC) throughout. Most unfortunately this period includes the Unix/Java epoch date of 1970-01-01 00:00.
This code:
Timestamp ts3 = Timestamp.valueOf("1970-01-01 00:00:00");
System.out.println("ts3="+ts3.getTime());
prints
ts3=-3600000
The behaviour is of course unchanged with the latest version (1.6 u10 as I write this).
Submitted On 18-NOV-2008
mthornton
Whoops, GMT did get fixed. But the UK civil timezone is not GMT (well it has the same offset for part of the year).
So adding
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
before the test code will give the correct result. The problem arises when using a time zone of "Europe/London".
Submitted On 21-JUL-2009
nikosdimitrakas
Very annoying bug. I create a java.sql.Time from a string with valueOf and then take the long provided by getTime() and use it to create java.sql.Timestamp or a java.util.Date and I am missing one hour. Please get this fixed. 7 years and it seems to survive to every new release.
Submitted On 21-OCT-2009
This is a very annoying bug indeed. It needs to be fixed.
Submitted On 12-NOV-2009
_dna_
I have exactly the same problem on Linux with java.sql.Time, very annoying.
Submitted On 13-NOV-2009
_dna_
The solution is using Calendar to get milliseconds value like this:
java.sql.Time time;
Calendar cal = new Calendar()
cal.setTime(time);
long ms = cal.getTimeInMillis();
Getting a milliseconds from 'time' to set Calendar makes the bug to appear.
It looks like this bug will never be fixed because of compatibility reasons.
Submitted On 13-NOV-2009
_dna_
Please remove my previous comment. My workaround does not work too. Sorry
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|