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

Wrong offset for TimeZone since release 1.7.0_45-b18

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 7u45
    • core-libs
    • b18
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.32-431.1.2.0.1.el6.x86_64

      A DESCRIPTION OF THE PROBLEM :
      There is a problem with the DST offset for certain timezones since release 1.7.0_45 (at least). In concrete "Africa/Casablanca" gives 0 offset for dates in July(when should be 3600).

      REGRESSION. Last worked in version 7u21

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
       I have a little test to prove it:

      import java.text.DateFormat;
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.GregorianCalendar;
      import java.util.TimeZone;

      public class MainTZTest
      {
          public static void main(String args[])
          {
              Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
              cal.set(Calendar.DATE, 20);
              cal.set(Calendar.MONTH, 6);
              cal.set(Calendar.YEAR, 2014);
              cal.set(Calendar.HOUR_OF_DAY, 7);
              cal.set(Calendar.MINUTE, 10);
              cal.set(Calendar.SECOND, 0);

              TimeZone timeZoneCB = TimeZone.getTimeZone("Africa/Casablanca");
              TimeZone timeZoneLisbon = TimeZone.getTimeZone("Europe/Lisbon");

              DateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
              sdf.setTimeZone(timeZoneCB);
              System.out.println(sdf.format(cal.getTime()));
              sdf.setTimeZone(timeZoneLisbon);
              System.out.println(sdf.format(cal.getTime()));

          }
      }

      Lisbon and Casablanca TZ should give the same output, but for casablanca it gives one hour less. This doesn't happen in 1.6 or 1.7.0_21 for example


      REPRODUCIBILITY :
      This bug can be reproduced always.

            okutsu Masayoshi Okutsu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: