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

(fmt) String.format() with a null Locale throws NullPointerException

    Details

    • Subcomponent:
    • Resolved In Build:
      b17
    • CPU:
      sparc
    • OS:
      solaris_9
    • Verification:
      Not verified

      Description

      I am producing a file that needs English/ASCII/C Locale. One part calls

         public static String yearday(Date d) {
          return String.format(null, "%te.%tb.%tY", d, d, d);
         }

      String.format documentation says the Local can be null:

          l - The locale to apply during formatting. If l is null then no localization
          is applied. This does not change this object's locale that was set during
          construction.

      However, attempting to pass the null Locale yields:

      Exception in thread "main" java.lang.NullPointerException
              at java.util.Calendar.createCalendar(Calendar.java:962)
              at java.util.Calendar.getInstance(Calendar.java:937)
              at java.util.Formatter$FormatSpecifier.printDateTime(Formatter.java:2738)
              at java.util.Formatter$FormatSpecifier.print(Formatter.java:2651)
              at java.util.Formatter.format(Formatter.java:2430)
              at java.util.Formatter.format(Formatter.java:2364)
              at java.lang.String.format(String.java:2564)
              at com.sun.WHATEVER.yearday(MYFILE.java:191)
      ###@###.### 2005-06-08 01:18:51 GMT

        Attachments

          Activity

            People

            • Assignee:
              iris Iris Clark
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: