public static OffsetDateTime from(TemporalAccessor temporal) {
        if (temporal instanceof OffsetDateTime) {
            return (OffsetDateTime) temporal;
        }
        try {
            ZoneOffset offset = ZoneOffset.from(temporal);
            try {
                LocalDateTime ldt = LocalDateTime.from(temporal);
                return OffsetDateTime.of(ldt, offset);
            } catch (DateTimeException ignore) {
                Instant instant = Instant.from(temporal);
                return OffsetDateTime.ofInstant(instant, offset);
            }
        } catch (DateTimeException ex) {
            throw new DateTimeException("Unable to obtain OffsetDateTime from TemporalAccessor: " +
                    temporal + ", type " + temporal.getClass().getName());
        }
    }
public static OffsetDateTime from ( TemporalAccessor temporal ) { if ( temporal instanceof OffsetDateTime ) { return ( OffsetDateTime ) temporal ; } try { ZoneOffset offset = ZoneOffset . from ( temporal ) ; try { LocalDateTime ldt = LocalDateTime . from ( temporal ) ; return OffsetDateTime . of ( ldt , offset ) ; } catch ( DateTimeException ignore ) { Instant instant = Instant . from ( temporal ) ; return OffsetDateTime . ofInstant ( instant , offset ) ; } } catch ( DateTimeException ex ) { throw new DateTimeException ( "Unable to obtain OffsetDateTime from TemporalAccessor: " + temporal + ", type " + temporal . getClass ( ) . getName ( ) ) ; } }
Obtains an instance of {@code OffsetDateTime} from a temporal object.
<p>
A {@code TemporalAccessor} represents some form of date and time information.
This factory converts the arbitrary temporal object to an instance of {@code OffsetDateTime}.
<p>
The conversion extracts and combines {@code LocalDateTime} and {@code ZoneOffset}.
If that fails it will try to extract and combine {@code Instant} and {@code ZoneOffset}.
<p>
This method matches the signature of the functional interface {@link TemporalQuery}
allowing it to be used in queries via method reference, {@code OffsetDateTime::from}.

@param temporal  the temporal object to convert, not null
@return the offset date-time, not null
@throws DateTimeException if unable to convert to an {@code OffsetDateTime}