Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6645293

(tz) Date is off by an hour on Linux

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • 7
    • 6
    • core-libs

        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.

              okutsu Masayoshi Okutsu
              peytoia Yuka Kamiya (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: