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

Calendar.setTime(Date date) throws NPE with Date date = null

XMLWordPrintable

    • b16
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      When setting time in Calendar.setTime(Date date), if 'Date date = null' then setTime() results nullPointerException since it is not able to call date.getTime() within itself. This problem needs null check, and possible default value setting if date = null.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the following in Java

      Date date = null;
      Calendar.setTime(date);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Possible default value setting?
      ACTUAL -
      NullPointerException

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: