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

Can not convert Calendar#getTimeInMillis() back to the original date

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      When we set 1986 January 1 to Java calendar instance, it doesn't return actual time in Millis, (ie always add extra 15 minutes)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      This issue occurs only for date:1986 January 1.
      1) First set Date 1986 January 1 to calendar instance with hour=0,minute=0,second=0,Millisecond=0
      2)Get/print time in Millis from above created calendar object
      3)when we convert this time in Millis to date again (convert using online tools or java code), it is seen that it's corresponding date is Wed Jan 01, 1986, 00:15:00 (but it should be Wed Jan 01, 1986, 00:00:00) ie extra 15 minutes added

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Want Actual time in Millis for Jan 01, 1986, 0 hours, 0 minutes, 0 seconds, 0 millisecond
      ACTUAL -
      504901800000
      Get Time in Millis for Jan 01, 1986, 0 hours, 15 minute

      ---------- BEGIN SOURCE ----------
        Calendar c = Calendar.getInstance();
        c.set(1986,0,1,0,0,0);
        c.set(Calendar.MILLISECOND,0);
        System.out.println(c.getTimeInMillis());

      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            Assignee:
            tongwan Andrew Wang
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: