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

SimpleTimeZone.getOffset returns incorrect value. DST is ignored.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.0, 1.1.1
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic, solaris_2.5

      Description

      The following code:

      $ cat TZTest.java
      import java.io.*;
      import java.util.*;

      public class TZTest {

        TZTest() {

          TimeZone time_zone = TimeZone.getDefault();

          System.out.println("The current time is :" + new Date());
          System.out.println("The timezone is "+time_zone.getID());

          if (time_zone.inDaylightTime(new Date()))
              System.out.println("in Daylight time");
          else
              System.out.println("not in Daylight time");

          if (time_zone.useDaylightTime())
              System.out.println("use Daylight time");
          else
              System.out.println("not use Daylight time");

          System.out.println("Raw offset in seconds: "+time_zone.getRawOffset());
          System.out.println("Raw offset in hours: "+
            time_zone.getRawOffset()/(1000*60*60));

          GregorianCalendar gc = new GregorianCalendar();
          gc.setTime(new Date());
          System.out.println("DST offset in seconds: "+
            time_zone.getOffset(gc.AD, gc.get(gc.YEAR), gc.get(gc.MONTH),
              gc.get(gc.DAY_OF_MONTH), gc.get(gc.DAY_OF_WEEK), 0));
          System.out.println("DST offset in hours: "+
            time_zone.getOffset(gc.AD, gc.get(gc.YEAR), gc.get(gc.MONTH),
              gc.get(gc.DAY_OF_MONTH), gc.get(gc.DAY_OF_WEEK), 0)/(1000*60*60));
               
        }
        
        public static void main(String argv[]) {
          new TZTest();
        }
      }

      returns an incorrect value for getOffset(). DST is ignored.

        Attachments

          Activity

            People

            Assignee:
            nlindenbsunw Norbert Lindenberg (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: