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

Calendar.getTime() does not return localized date and time. It always returns GM

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P3
    • None
    • 1.1
    • core-libs
    • x86
    • windows_95

    Description



      Name: mc57594 Date: 02/07/97


      System.out.println("Current Time");
      SimpleTimeZone mez = new SimpleTimeZone(+1 * 60 * 60 * 1000, "Berlin");
      mez.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
      mez.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
      Calendar calendar = new GregorianCalendar(mez);
      Date trialTime = new Date();
      calendar.setTime(trialTime);
      System.out.println("TIME: " + calendar.getTime());

      The timevalue returned by Calendar.getTime() differs from the timefieldvalues of the Calendar-class (DATE, HOUROFDAY etc.)
      in that is does not use Calendar.ZONEOFFSET. Instead ist always returns GMT time (e.g. NOT local time).
      company - Technical University of Berlin, Germany , email - ###@###.###
      ======================================================================

      [Sheri Good 03/06/97] Here is a user with a the same time zone problem in
      MET (Middle European Time)

      From: Bjoern-Arne Meyn <###@###.###>

      Subcategory: classes_util
      Bug/rfe/eou: bug
      Synopsis: TimeZone.getDefault() always returns GMT as current timezone
      Description: On my computer running under Windows 95, the default timezone is MET (Middle European Time = GMT + 1 / +2 DST). Java code such as the following should return MET as default timzone and a raw offset of 1 (* 60 * 60 * 1000).

      SimpleTimeZone stz = (SimpleTimeZone)SimpleTimeZone .getDefault();
      System.out.println(stz.getID());
      System.out.println(stz.getRawOffset() / (60 * 60 * 1000));

      The values returned by the code are GMT and 0, no matter what the actual timezone is. If I change the timezone in my system's configuration, to EST for example, Java fails to notice this and still returns the values above.

      company - , email - ###@###.###
      Work around:


      Comments:
      customer_rec: new
      Company: other
      Employee:Bjoern-Arne Meyn
      Release: jdk11
      Hardware Version: i586
      O/S version: win_95
      User Role: D
      User Type: E
      Sun Contact: (internal)
      end_customer_rec:
      BUG_END

      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              nlindenbsunw Norbert Lindenberg (Inactive)
              mchamnessunw Mark Chamness (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: