Solution here and now:
System.setProperty("java.locale.providers", "COMPAT,CLDR");
String dateString = "Mi Mai 09 09:17:24 2018";
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss yyyy", Locale.GERMAN);
LocalDateTime dateTime = LocalDateTime.parse(dateString, dtf);
System.out.println(dateTime);
Output (tested on Java 9 and Java 10):
2018-05-09T09:17:24
The only change from your code is I have inserted System.setProperty("java.locale.providers", "COMPAT,CLDR"); at the beginning of the program. According to the documentation this shouldn’t really work, but it did when I tried it. Instead the correct way is to supply the same system property on the command line when running your Java program. For example:
java -Djava.locale.providers=COMPAT,CLDR com.ajax.ParseTwoLetterDayOfWeekAbbreviationInGerman
Thanks to Joep Weijers for pointing out in a comment that the property must be set on the command line. Funnily the same system property broke the code on my Java 8.
More modern solution:
String dateString = "Mi. Mai 09 09:17:24 2018";
I have required a dot (a period) after Mi in the string to signify that it is an abbreviation.
Locale providers
To parse a date in German Java needs so-called locale data, including the names and abbreviations for days of the week and for months used in German and other languages. To confuse things, these data come from more than one source. In all of Java 8, 9 and 10 Java contains locale data from at least two sources, Java’s own locale data and standardized locale data from CLDR, Unicode Common Locale Data Repository (I don’t know if there is one or two more sources). In Java 8 Java’s own data were the default and you would need to specify CLDR if you wanted those data instead. In Java 9 and later it’s the other way around: CLDR is the default, but the old Java data are available as COMPAT. This explains the comment by soon that your code works on Java 8, but fails on Java 10.
And apparently the Java locale data have Mi without a dot as abbreviation for Mittwoch (Wednesday), while CLDR has Mi. with a dot. There are many other differences.
Links
EE, as you used, is a numeric format, parsingMiwould probably require usnigEEE.