private static Interval parseEndDateTime ( Instant start , ZoneOffset offset , CharSequence endStr ) { try { TemporalAccessor temporal = DateTimeFormatter . ISO_DATE_TIME . parseBest ( endStr , OffsetDateTime :: from , LocalDateTime :: from ) ; if ( temporal instanceof OffsetDateTime ) { OffsetDateTime odt = ( OffsetDateTime ) temporal ; return Interval . of ( start , odt . toInstant ( ) ) ; } else { // infer offset from start if not specified by end LocalDateTime ldt = ( LocalDateTime ) temporal ; return Interval . of ( start , ldt . toInstant ( offset ) ) ; } } catch ( DateTimeParseException ex ) { Instant end = Instant . parse ( endStr ) ; return Interval . of ( start , end ) ; } }
parse when there are two date - times