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

get(Calendar.MONTH) gets the previous month of any given date passed

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      execute the following:
      Calendar rightNow= Calendar.getInstance();
      rightNow.get(Calendar.MONTH);

      The get(Calendar.MONTH) method returns the previous month of the given date instead of the current month. If you execute this on Sept 19 2019, it will return august as the month.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      execute the following:
      Calendar rightNow= Calendar.getInstance();
      rightNow.get(Calendar.MONTH);

      The get(Calendar.MONTH) method returns the previous month of the given date instead of the current month. If you execute this on Sept 19 2019, it will return august as the month.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Return the month of the date being passed instead of the previous month
      ACTUAL -
      Returns the previous month of the given date passed

      ---------- BEGIN SOURCE ----------
      execute the following:
      Calendar rightNow= Calendar.getInstance();
      rightNow.get(Calendar.MONTH);

      The get(Calendar.MONTH) method returns the previous month of the given date instead of the current month. If you execute this on Sept 19 2019, it will return august as the month.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      add +1 to the result returned

      FREQUENCY : always


        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: