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

TimeZone.getTimeZone is returning wrong value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8u172
    • core-libs
    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10

      A DESCRIPTION OF THE PROBLEM :
      When I am trying to get time with TimeZone.getTimeZone("GMT+5:30") and formatting it with SimpleDateFormat.setTimeZone for new Date(), it is returning 2019 year.

      TimeZone.getTimeZone(GMT+5:30) = sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
      dt = Mon Dec 31 15:09:24 IST 2018
      rdate2 = 31/12/2019 At 15:09:24

      REGRESSION : Last worked in version 8u172

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      SimpleDateFormat dtFormatDate1 =new SimpleDateFormat("dd/MM/YYYY");
      SimpleDateFormat dtFormatTime1 =new SimpleDateFormat("HH:mm:ss");
      dtFormatDate1.setTimeZone(TimeZone.getTimeZone("GMT+5:30"));
      dtFormatTime1.setTimeZone(TimeZone.getTimeZone("GMT+5:30"));
      String rdate2 = dtFormatDate1.format(dt)+" At "+ dtFormatTime1.format(dt);
      System.out.println("rdate2 = "+rdate2);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      rdate2 = 31/12/2018 At 15:09:24
      ACTUAL -
      rdate2 = 31/12/2019 At 15:09:24

      FREQUENCY : rarely


            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: