title: SimpleDateFormat with German Locale - Java 8 vs Java 10+
body: <p>I have code and a test-case in a <strong>legacy</strong> application, which can be summarized as follows:</p>
  <pre><code>@Test
  public void testParseDate() throws ParseException {
      String toParse = &quot;Mo Aug 18 11:25:26 MESZ +0200 2014&quot;;
      String pattern = &quot;EEE MMM dd HH:mm:ss z Z yyyy&quot;;
  
      DateFormat dateFormatter = new SimpleDateFormat(pattern, Locale.GERMANY);
      Date date = dateFormatter.parse(toParse);
  
      //skipped assumptions
  }
  </code></pre>
  <p>This test passes in Java 8 and below. However with Java 10 upwards this leads to a <code>java.text.ParseException: Unparseable date: &quot;Mo Aug 18 11:25:26 MESZ +0200 2014&quot;</code>.</p>
  <p><em>For the record</em>:
  Besides <code>de_DE</code>, the exception is also thrown for the locales
  <code>de_CH</code>, <code>de_AT</code>, <code>de_LU</code>.</p>
  <p>I am aware of the fact, that Date formatting was <a href="https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-A20F2989-BFA9-482D-8618-6CBB4BAAE310" rel="noreferrer">changed with JDK 9</a> (<a href="http://openjdk.java.net/jeps/252" rel="noreferrer">JEP 252</a>). However, I consider this to be a disruptive change breaking backwards compatibility. Excerpted:</p>
  <blockquote>
  <p>In JDK 9, the Unicode Consortium's Common Locale Data Repository (CLDR) data is enabled as the default locale data, so that you can use standard locale data without any further action.</p>
  <p>In JDK 8, although CLDR locale data is bundled with the JRE, it isn’t enabled by default.</p>
  <p>Code that uses locale-sensitive services such as date, time, and number formatting may produce different results with the CLDR locale data.</p>
  </blockquote>
  <p>Adding a <code>.</code> for the day of the week (<code>Mo.</code>) compensates for this and test would pass. However, this is not a real solution for old data (in serialized form such as XML).</p>
  <p>Checking this <a href="https://stackoverflow.com/questions/46244724/jdk-dateformater-parsing-dayofweek-in-german-locale-java8-vs-java9/46245412#46245412">stackoverflow post</a>, it seems that the behaviour is intentional for the German locale and can be mitigated by specifying <code>java.locale.providers</code> with <code>COMPAT</code> mode. However, I do not like the idea to rely on some system property value for two reasons as it might:</p>
  <ol>
  <li>change in the next releases of the JDK.</li>
  <li>be forgotten in different environments.</li>
  </ol>
  <p><strong>My question is:</strong></p>
  <ul>
  <li>How can I maintain backwards compatibility of legacy code with this particular date pattern, without re-writing / modifying existing serialized data or adding / changing system properties (like <code>java.locale.providers</code>), which may be forgotten in different environments (application servers, standalone jars, ...) ?</li>
  </ul>