title: Java 8 Date and Time: parse ISO 8601 string without colon in offset
body: <p>We try to parse the following ISO 8601 DateTime String with timezone offset:</p>
  
  <pre class="lang-java prettyprint-override"><code>final String input = "2022-03-17T23:00:00.000+0000";
  
  OffsetDateTime.parse(input);
  LocalDateTime.parse(input, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
  </code></pre>
  
  <p>Both approaches fail (which makes sense as <code>OffsetDateTime</code> also use the <code>DateTimeFormatter.ISO_OFFSET_DATE_TIME</code>) because of the colon in the timezone offset.   </p>
  
  <blockquote>
    <p>java.time.format.DateTimeParseException: Text '2022-03-17T23:00:00.000+0000' could not be parsed at index 23</p>
  </blockquote>
  
  <p>But according to <a href="https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators" rel="noreferrer">Wikipedia</a> there are 4 valid formats for a timezone offset: </p>
  
  <pre><code>&lt;time&gt;Z 
  &lt;time&gt;±hh:mm 
  &lt;time&gt;±hhmm 
  &lt;time&gt;±hh
  </code></pre>
  
  <p>Other frameworks/languages can parse this string without any issues, e.g. the Javascript <code>Date()</code> or Jacksons <code>ISO8601Utils</code> (they discuss this issue <a href="https://github.com/FasterXML/jackson-databind/issues/919" rel="noreferrer">here</a>)</p>
  
  <p>Now we could write our own <code>DateTimeFormatter</code> with a complex RegEx, but in my opinion the <code>java.time</code> library should be able to parse this valid ISO 8601 string by default as it is a valid one. </p>
  
  <p>For now we use Jacksons <code>ISO8601DateFormat</code>, but we would prefer to use the official <code>date.time</code> library to work with. What would be your approach to tackle this issue?</p>