title: java 8 compare datetime, with zoned time
body: <p>How do I check if request is in between this window? I have a time of request as 2011-12-03T15:15:30-05:00 and a time window which could be defined in any zone, example 09:00:00+00:00 and 17:00:00+00:00.</p>
  
  <p>Now if i parse the datetime to LocalTime i loose the timezone.</p>
  
  <pre><code>public LocalTime time(String time){
  
      return LocalTime.from(DateTimeFormatter.ISO_OFFSET_TIME.parse(time));
  }
  
  
  
  private ZonedDateTime dateTime(String dateTime){
      return ZonedDateTime.from(DateTimeFormatter.ISO_DATE_TIME.parse(dateTime));
  }
  </code></pre>
  
  <p>//Compare function</p>
  
  <pre><code>public boolean compare(ZonedDateTime dateTime, LocalTime localTime, LocalTime localTime2) {
  
      LocalTime time = dateTime.withZoneSameInstant(utc).toLocalTime();
  
  
      int start = time.compareTo(localTime);
      int end = time.compareTo(localTime2);
  
      return start &gt;= 0 &amp;&amp; end &lt;= 0;
  
  }
  </code></pre>
  
  <p>now i invoke the above compare function as:</p>
  
  <pre><code>service.compare(dateTime("2011-12-03T15:15:30-05:00"), time("09:00:00+00:00"), time("17:00:00+00:00")); 
  </code></pre>