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

(cal) SimpleDateFormat.setTimeZone(TimeZone) does not throw NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs

      FULL PRODUCT VERSION :
      1.4.x

      ADDITIONAL OS VERSION INFORMATION :
      win2ksp4

      A DESCRIPTION OF THE PROBLEM :
      SimpleDateFormat.setTimeZone(TimeZone) (or perhaps some base class) does not throw a NPE if a null is passed in.

      This may create difficult to trace / ambiguous NPEs at a later time, such as in the exmaple of calling DateFormat.format():

      java.lang.NullPointerException
      at java.util.GregorianCalendar.computeFieldsImpl(GregorianCalendar.java:1321)
      at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1298)
      at java.util.Calendar.setTimeInMillis(Calendar.java:927)
      at java.util.Calendar.setTime(Calendar.java:902)
      at java.text.SimpleDateFormat.format(SimpleDateFormat.java:782)
      at java.text.SimpleDateFormat.format(SimpleDateFormat.java:775)
      at java.text.DateFormat.format(DateFormat.java:314)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Pass a null to SimpleDateFormat.setTimeZone; no Exception is thrown.


      REPRODUCIBILITY :
      This bug can be reproduced always.

            okutsu Masayoshi Okutsu
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: