JDK-6645293 : (tz) Date is off by an hour on Linux
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2007-12-25
  • Updated: 2010-07-29
  • Resolved: 2009-11-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u18Resolved 7Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
rshillington@rubin:/temp/dateTest$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Ubuntu 7.04 Fiesty

A DESCRIPTION OF THE PROBLEM :
When you print new Date() on Linux, it's the wrong time as of October 29, 2007.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I've narrowed the problem down to the following super simple program:

import java.util.*;
import java.text.*;

public class DateTest
{
        public static void main(String args[])
        {
                SimpleDateFormat format = new SimpleDateFormat("MM.dd.yyyy-HH.mm.ss zzz");
                System.out.println("Formated current date and time is " + format.format(new Date()));
                System.out.println("Raw current date and time is " + new Date());
        }
}

When I run it on Linux, as of yesterday October 29th it started displaying the wrong time:

rshillington@rubin:/temp/dateTest$ date
Tue Oct 30 22:23:24 CDT 2007
rshillington@rubin:/temp/dateTest$ java -classpath . DateTest
Formated current date and time is 10.30.2007-21.23.40 CST
Raw current date and time is Tue Oct 30 21:23:40 CST 2007
rshillington@rubin:/temp/dateTest$

It's an hour off!  This doesn't happen on Windows:

C:\temp>echo %DATE% %TIME%
Tue 10/30/2007 22:25:45.43

C:\temp>java -classpath . DateTest
Formated current date and time is 10.30.2007-22.25.52 CDT
Raw current date and time is Tue Oct 30 22:25:52 CDT 2007

Sucks.  My program depends on looking for a report generated from a remote service in the last 15 minutes, but it's always looking for the report to be generated an hour ago.




EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I'd expect the time to be the same as the system time.
ACTUAL -
The time is an hour off.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import java.util.*;
import java.text.*;

public class DateTest
{
        public static void main(String args[])
        {
                SimpleDateFormat format = new SimpleDateFormat("MM.dd.yyyy-HH.mm.ss zzz");
                System.out.println("Formated current date and time is " + format.format(new Date()));
                System.out.println("Raw current date and time is " + new Date());
        }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Set your computer clock forward an hour until next Sunday?  I don't know.

Comments
EVALUATION Closing this CR as a duplicate of 6456628.
04-11-2009

EVALUATION Need to support /etc/timezone for Ubuntu.
02-07-2009