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

SimpleDateFormat add extra point to short month name in german

    XMLWordPrintable

Details

    • b01
    • 17

    Description

      ADDITIONAL SYSTEM INFORMATION :
      openjdk version "17-ea" 2021-09-14
      OpenJDK Runtime Environment (build 17-ea+28-2534)
      OpenJDK 64-Bit Server VM (build 17-ea+28-2534, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      The SimpleDateFormat add an extra point for short month names (pattern MMM) in German. This extra point is needing for parsing and also print on formatting a data. It look like the localized names contains the extra point. For the English locale it is working like expected.

      With Java 17 the parsing is failing which make the problem visible. With Java 11 the formatting is already wrong.

      REGRESSION : Last worked in version 11.0.11

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Germany without point
      Thu Feb 20 00:00:00 CET 2003
      Feb 20, 2003
      US without point
      Thu Feb 20 00:00:00 CET 2003
      Feb 20, 2003
      Germany with point
      Feb. 20, 2003
      US with point
      Feb. 20, 2003
      ACTUAL -
      Germany without point
      null
      Feb. 20, 2003
      US without point
      Thu Feb 20 00:00:00 CET 2003
      Feb 20, 2003
      Germany with point
      Feb.. 20, 2003
      US with point
      Feb. 20, 2003

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

      public class SimleDateFormatTest {

          public static void main( String[] args ) {
              String x = "Feb 20, 2003";
              Date d = new Date( 103, 1, 20);
              DateFormat formatter;

              System.out.println( "Germany without point" );
              formatter = new SimpleDateFormat( "MMM dd, yyyy", Locale.GERMANY );
              System.out.println( "\t" + formatter.parse( x, new ParsePosition( 0 ) ) );
              System.out.println( "\t" + formatter.format( d ) );
              
              System.out.println( "US without point" );
              formatter = new SimpleDateFormat( "MMM dd, yyyy", Locale.US );
              System.out.println( "\t" + formatter.parse( x, new ParsePosition( 0 ) ) );
              System.out.println( "\t" + formatter.format( d ) );

              System.out.println( "Germany with point" );
              formatter = new SimpleDateFormat( "MMM. dd, yyyy", Locale.GERMANY );
              System.out.println( "\t" + formatter.format( d ) );

              System.out.println( "US with point" );
              formatter = new SimpleDateFormat( "MMM. dd, yyyy", Locale.US );
              System.out.println( "\t" + formatter.format( d ) );
          }

      }

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

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              naoto Naoto Sato
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: