title: What MIN/MAX values will work with both ZonedDateTime and Instant.toEpochMilli?
body: <p>I want to use MIN/MAX time values that can convert between <code>ZonedDateTime</code> and <code>Instant.toEpochMilli()</code>, to be used as sentinel values for a filter/query.</p>
  
  <p>I tried:</p>
  
  <pre><code>OffsetDateTime.MIN.toInstant().toEpochMilli();
  OffsetDateTime.MAX.toInstant().toEpochMilli();
  </code></pre>
  
  <p>but I get this exception:</p>
  
  <pre><code>java.lang.ArithmeticException: long overflow
  
      at java.lang.Math.multiplyExact(Math.java:892)
      at java.time.Instant.toEpochMilli(Instant.java:1237)
  </code></pre>
  
  <p>And then I tried this:</p>
  
  <pre><code>ZonedDateTime.ofInstant(Instant.MIN, ZoneId.systemDefault());
  ZonedDateTime.ofInstant(Instant.MAX, ZoneId.systemDefault());
  </code></pre>
  
  <p>but then I get this exception:</p>
  
  <pre><code>java.time.DateTimeException: Invalid value for Year (valid values -999999999 - 999999999): -1000000001
  
      at java.time.temporal.ValueRange.checkValidIntValue(ValueRange.java:330)
      at java.time.temporal.ChronoField.checkValidIntValue(ChronoField.java:722)
      at java.time.LocalDate.ofEpochDay(LocalDate.java:341)
      at java.time.LocalDateTime.ofEpochSecond(LocalDateTime.java:422)
      at java.time.ZonedDateTime.create(ZonedDateTime.java:456)
      at java.time.ZonedDateTime.ofInstant(ZonedDateTime.java:409)
  </code></pre>
  
  <p>I also tried 'Z' <code>ZoneId</code>:</p>
  
  <pre><code>ZonedDateTime.ofInstant(Instant.MIN, ZoneId.of("Z"))
  </code></pre>
  
  <p>but that returns the same exception as the last one.</p>
  
  <p>Finally I tried the following, and it seems to work:</p>
  
  <pre><code>ZonedDateTime.ofInstant(Instant.EPOCH, ZoneId.of("Z"));
  ZonedDateTime.ofInstant(Instant.EPOCH.plusMillis(Long.MAX_VALUE), ZoneId.of("Z"));
  </code></pre>
  
  <p>Is that the best solution?</p>