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

SimpleDateFormat - parse bug - regional settings Romania - month November

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      java.text.SimpleDateFormat parse method gives a java.lang.NullPointer Exception when I parse the the string "10Noi 05" with the pattern "ddMMM yy" and windows regional settings set to Romania.
      When I replace "Noi" with "Nov" and same regional setting, there is no exceptions. With every other month (Ian, Mai, Iun,Iul in romanian) is working properly. In romanian language "November" is "Noiembrie", so the first three letters for November are "Noi" for Romania Locale.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Set Windows Regional Settings to Romania
      compile and run in a program the following lines like in my example.

      System.out.println((sdf.parse("10Noi 05",new ParsePosition(0))).toString()); // should work but it gives an exception

      System.out.println((sdf.parse("10Nov 05",new ParsePosition(0))).toString()); //should give an exception but is working






      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should display "Thu Nov 10 00:00:00 EET 2005"
      ACTUAL -
      gives a NullPointerException


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.NullPointerException
              at Fisier.main(NovemberBug.java:19)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import java.text.*;

      public class NovemberBug {


      public static void main (String[] args) throws Exception {

             java.util.Locale lc = java.util.Locale.getDefault();
             System.out.println("---- Regional settings set to: "+lc.getCountry());

      SimpleDateFormat sdf= new SimpleDateFormat("ddMMM yy");
      System.out.println((sdf.parse("13Ian 05",new ParsePosition(0))).toString());
      System.out.println((sdf.parse("10Mai 05",new ParsePosition(0))).toString());
      System.out.println((sdf.parse("10Iun 05",new ParsePosition(0))).toString());
      System.out.println((sdf.parse("10Iul 05",new ParsePosition(0))).toString());
      System.out.print((sdf.parse("10Nov 05",new ParsePosition(0))).toString()); System.out.println("!!!!!! -- Should give an exception with regional setings set to Romania");

      System.out.println((sdf.parse("10Noi 05",new ParsePosition(0))).toString()); // Here it gives a NullPointer Exception
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Replace "Noi" string with "Nov"
      ###@###.### 2005-03-09 11:57:15 GMT
      I have contacted the customer to provide more information related to this bug. I will keep you updated if the customer provides an updated related to this.

            jtusla Jiri Tusla (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: