-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
9.0.1
-
x86_64
-
linux_ubuntu
FULL PRODUCT VERSION :
java 9.0.1
ADDITIONAL OS VERSION INFORMATION :
Linux saber-ubuntu 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
java.text.DateFormat parsing error with Locale.German on dates with DD MMM YYYY format.
e.g., parsing "31 Dez 2005" with format "dd MMM yyyy"
with
DateFormat.parseObject();
See more details in attached test case.
REGRESSION. Last worked in version 8u152
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The test case pass
ACTUAL -
The test case throws a null pointer exception, as the parsing fails.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package edu.utsa.cs.test4incomp;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import org.junit.Test;
import junit.framework.TestCase;
public class TestLocaleParse extends TestCase{
@Test
public void testLocaleParse(){
String germanVal = "31 Dez 2005";
String germanPattern = "dd MMM yyyy";
Calendar cal = (Calendar)parse(germanVal, germanPattern, Locale.GERMAN);
cal.getTime();
}
protected Object parse(String value, String pattern, Locale locale) {
DateFormatSymbols symbols = new DateFormatSymbols(locale);
DateFormat formatter = new SimpleDateFormat(pattern, symbols);
formatter.setLenient(false);
ParsePosition pos = new ParsePosition(0);
formatter.parseObject(value, pos);
if (pos.getErrorIndex() > -1) {
return null;
}
return ((DateFormat)formatter).getCalendar();
}
}
---------- END SOURCE ----------
java 9.0.1
ADDITIONAL OS VERSION INFORMATION :
Linux saber-ubuntu 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
java.text.DateFormat parsing error with Locale.German on dates with DD MMM YYYY format.
e.g., parsing "31 Dez 2005" with format "dd MMM yyyy"
with
DateFormat.parseObject();
See more details in attached test case.
REGRESSION. Last worked in version 8u152
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The test case pass
ACTUAL -
The test case throws a null pointer exception, as the parsing fails.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package edu.utsa.cs.test4incomp;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import org.junit.Test;
import junit.framework.TestCase;
public class TestLocaleParse extends TestCase{
@Test
public void testLocaleParse(){
String germanVal = "31 Dez 2005";
String germanPattern = "dd MMM yyyy";
Calendar cal = (Calendar)parse(germanVal, germanPattern, Locale.GERMAN);
cal.getTime();
}
protected Object parse(String value, String pattern, Locale locale) {
DateFormatSymbols symbols = new DateFormatSymbols(locale);
DateFormat formatter = new SimpleDateFormat(pattern, symbols);
formatter.setLenient(false);
ParsePosition pos = new ParsePosition(0);
formatter.parseObject(value, pos);
if (pos.getErrorIndex() > -1) {
return null;
}
return ((DateFormat)formatter).getCalendar();
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8269564 SimpleDateFormat add extra point to short month name in german
-
- Closed
-
-
JDK-8304558 DateFormat.parse fails for date in dd-MMM-yyyy format
-
- Closed
-