-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
17
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
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
- duplicates
-
JDK-8194289 java.text.DateFormat parsing error with Locale.German
- Closed
-
JDK-8209986 SimpleDateFormat adds extra "." for some locales
- Closed