private static Interval parseStartExtended ( CharSequence startStr , CharSequence endStr ) { Instant start = Instant . parse ( startStr ) ; if ( endStr . length ( ) > 0 ) { char c = endStr . charAt ( 0 ) ; if ( c == ' ' || c == ' ' ) { PeriodDuration amount = PeriodDuration . parse ( endStr ) ; // addition of PeriodDuration only supported by OffsetDateTime, // but to make that work need to move point being added to closer to EPOCH long move = start . isBefore ( Instant . EPOCH ) ? 1000 * 86400 : - 1000 * 86400 ; Instant end = start . plusSeconds ( move ) . atOffset ( ZoneOffset . UTC ) . plus ( amount ) . toInstant ( ) . minusSeconds ( move ) ; return Interval . of ( start , end ) ; } } // infer offset from start if not specified by end return parseEndDateTime ( start , ZoneOffset . UTC , endStr ) ; }
handle case where Instant is outside the bounds of OffsetDateTime