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

Unparseable date: 22 lutego 2012 by DateFormat in Polish locale

XMLWordPrintable

      FULL PRODUCT VERSION :
      JDK1.7.0_01

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7

      A DESCRIPTION OF THE PROBLEM :
      SimpleDateFormat class gives invalid date for "29-lutego-2012", however it validates and parse 29-luty-2012

      lutego and luty means February in english locale.

      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Set Polish locale to your Java application
      2. Create instance of SimpleDateFormat
      3. Pass string value 22 lutego 2012 to parse

      See the code snippet:



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Value should parse and display "Wed Feb 22 00:00:00 IST 2012" on console
      ACTUAL -
      Exception

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.text.ParseException: Unparseable date: "22 lutego 2012"
      at java.text.DateFormat.parse(Unknown Source)
      at TestDateFormat.main(TestDateFormat.java:22)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.text.DateFormat;
      import java.text.ParseException;
      import java.text.SimpleDateFormat;
      import java.util.Date;
      import java.util.Locale;


      public class TestPolishDateFormat {
      public static void main(String[] args) {
      Locale locale = new Locale("pl", "PL");
      //Set polish local
      Locale.setDefault(locale);
      //Get instance of SimpleDateFormat
      SimpleDateFormat longFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.LONG);

      try {

      Date date = longFormat.parse("22 luty 2012"); // This value parse successfully
      System.out.println(date);

      date = longFormat.parse("22 lutego 2012"); // This fails
      System.out.println(date);
      } catch (ParseException e) {
      e.printStackTrace();
      }
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      For Polish locale use luty instead of lutego for February month

            yhuang Yong Huang (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: