Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.9.0-ea" Java(TM) SE Runtime Environment (build 1.9.0-ea-b71) Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b71, mixed mode) ADDITIONAL OS VERSION INFORMATION : OS independent A DESCRIPTION OF THE PROBLEM : Build 71 started to use the CLDR locale data by default. This causes several problems when parsing dates (in some locales, especially the neutrale Locale.ROOT) REGRESSION. Last worked in version 9 ADDITIONAL REGRESSION INFORMATION: java version "1.9.0-ea" Java(TM) SE Runtime Environment (build 1.9.0-ea-b71) Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b71, mixed mode) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Apache Lucene / Solr needs to parse dates from strings. Because Solr is language neutral, it uses Locale.ROOT when parsing dates. Any date that contains time zone identifiers or weekdays cannot be parsed anymore in this Locale. JDK-8129881 mentions that some locales are missing this information, so this would explain this. I think this is exactly the same problem. In addition, the system is not even able to parse new Date().toString() using the ROOT Locale. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Date should parse with SimpleDateFormat ACTUAL - Exception, date cannot be parsed with ROOT locale ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.text.ParseException: Unparseable date: "Thu Nov 13 04:35:51 AKST 2008" at java.text.DateFormat.parse(DateFormat.java:366) at Bug.main(Bug.java:9) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Locale; public final class Bug { public static void main(String[] args) throws ParseException { SimpleDateFormat fmt = new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy", Locale.ROOT); fmt.parse("Thu Nov 13 04:35:51 AKST 2008"); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Pass -Djava.locale.providers=JRE,SPI to use old locale date as of JDK 7/8. Alternatively use Locale.ENGLISH.
|