title: Parsing ZonedDateTime with Java 8 DateTimeFormatter
body: <p>I am trying to create a ZonedDateTime with a DateTimeFormatter by using the following pattern <code>"dd-mm-yyyy'T'HH:mmZ"</code>:</p>
  
  <pre><code>public static ZonedDateTime timeFromDayMonthYearHHmmTZ(String dateTime){
          DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mmZ");
          return ZonedDateTime.parse(dateTime, formatter);
      }
  </code></pre>
  
  <p>Using the previous code, the following expression parses correctly:</p>
  
  <pre><code>ZonedDateTime dateTime1 = ZonedDateTimeUtils.dateTimeFromDayMonthYearHHmmTZ("25-01-2018T15:30-0100");
  </code></pre>
  
  <p>However, the next expression generates an exception (notice the <code>:</code> in the TZ offset):</p>
  
  <pre><code>ZonedDateTime dateTime2 = ZonedDateTimeUtils.dateTimeFromDayMonthYearHHmmTZ("25-01-2018T15:30-01:00");
  </code></pre>
  
  <p>My understanding is that <code>Z</code> in the pattern <code>"dd-mm-yyyy'T'HH:mmZ"</code> should cover both cases? However I am getting the following exception:</p>
  
  <pre><code>java.time.format.DateTimeParseException: Text '25-01-2018T15:30-01:00' could not be parsed at index 16
  </code></pre>
  
  <p>Ideally I would like to have a flexible solution where I can parse both patterns.</p>