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

DateFormat won't accept Czech locale, cs_CZ Short Months (Roman Numerals)

XMLWordPrintable

      FULL PRODUCT VERSION :
      $ java -version
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+99-2015-12-23-184955.javare.4146.nc)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+99-2015-12-23-184955.javare.4146.nc, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X El Capitan 10.11.2

      A DESCRIPTION OF THE PROBLEM :
      Building maven-changes-plugin using Java 9 ea b99 on mac, a test fails because the test believes "06 XII 2010" is a valid date for 2010-12-06 (ISO_8601).

      Doing some quick research it looks like the test is valid and DateFormat is wrong. see http://www.localeplanet.com/java/cs-CZ/


      REGRESSION. Last worked in version 8u60

      ADDITIONAL REGRESSION INFORMATION:
      Simply changing from Java 9 to Java 8 and doing 'mvn clean install' again, all tests pass.

      $ java -version
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      git clone https://github.com/apache/maven-plugins ;
      cd maven-plugins/maven-changes-plugin ;
      JAVA_HOME=`/usr/libexec/java_home -v 1.8` ; export JAVA_HOME ;
      mvn clean install ;
      JAVA_HOME=`/usr/libexec/java_home -v 9` ; export JAVA_HOME ;
      mvn clean install ;


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      tests pass in Java 8
      tests pass in Java 9
      ACTUAL -
      tests pass in Java 8
      tests fail in Java 9

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.text.ParseException: Unparseable date: "06 XII 2010"
          at java.text.DateFormat.parse(DateFormat.java:366)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
              // pattern with months as text
              String pattern = "dd MMM yyyy";

              // Czech locale
              String locale = "cs_CZ";

                  Locale usedLocale = null;

                      Locale[] locales = Locale.getAvailableLocales();
                      for ( int i = 0; i < locales.length; i++ )
                      {
                          if ( locales[i].toString().equals( locale ) )
                          {
                              usedLocale = locales[i];
                              break;
                          }
                      }

                  SimpleDateFormat df = new SimpleDateFormat( pattern, usedLocale );
                  df.parse( string );

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

      CUSTOMER SUBMITTED WORKAROUND :
      I skip that test assert statement to check everything else works fine apart from this one issue.

      I've never used cs_CZ locale, I'm just trying to help out testing OpenJDK.

            okutsu Masayoshi Okutsu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: