public static Instant fromMillisOrIso8601(String time, String fieldName) {
    try {
      return Instant.ofEpochMilli(Long.parseLong(time));
    } catch (NumberFormatException nfe) {
      // TODO: copied from PluginConfigurationProcessor, find a way to share better
      try {
        DateTimeFormatter formatter =
            new DateTimeFormatterBuilder()
                .append(DateTimeFormatter.ISO_DATE_TIME)
                .optionalStart()
                .appendOffset("+HHmm", "+0000")
                .optionalEnd()
                .toFormatter();
        return formatter.parse(time, Instant::from);
      } catch (DateTimeParseException dtpe) {
        throw new IllegalArgumentException(
            fieldName
                + " must be a number of milliseconds since epoch or an ISO 8601 formatted date");
      }
    }
  }
@Test
  public void testFromMillisOrIso8601_iso8601() {
    Instant parsed = Instants.fromMillisOrIso8601("2020-06-08T14:54:36+00:00", "ignored");
    Assert.assertEquals(Instant.parse("2020-06-08T14:54:36Z"), parsed);
  }