@Override public ZoneOffset queryFrom(TemporalAccessor temporal) { return ZoneOffset.from(temporal); } };
@Override public ZoneOffset queryFrom(TemporalAccessor temporal) { return ZoneOffset.from(temporal); } };
/** * Obtains an instance of {@code OffsetTime} 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 OffsetTime}. * <p> * The conversion extracts and combines {@code LocalTime} 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 OffsetTime::from}. * * @param temporal the temporal object to convert, not null * @return the offset time, not null * @throws DateTimeException if unable to convert to an {@code OffsetTime} */ public static OffsetTime from(TemporalAccessor temporal) { if (temporal instanceof OffsetTime) { return (OffsetTime) temporal; } try { LocalTime time = LocalTime.from(temporal); ZoneOffset offset = ZoneOffset.from(temporal); return new OffsetTime(time, offset); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain OffsetTime from TemporalAccessor: " + temporal + ", type " + temporal.getClass().getName()); } }
/** * Obtains an instance of {@code OffsetTime} 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 OffsetTime}. * <p> * The conversion extracts and combines {@code LocalTime} 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 OffsetTime::from}. * * @param temporal the temporal object to convert, not null * @return the offset time, not null * @throws DateTimeException if unable to convert to an {@code OffsetTime} */ public static OffsetTime from(TemporalAccessor temporal) { if (temporal instanceof OffsetTime) { return (OffsetTime) temporal; } try { LocalTime time = LocalTime.from(temporal); ZoneOffset offset = ZoneOffset.from(temporal); return new OffsetTime(time, offset); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain OffsetTime from TemporalAccessor: " + temporal + ", type " + temporal.getClass().getName()); } }
ZoneOffset offset = ZoneOffset.from(temporal); try { LocalDateTime ldt = LocalDateTime.from(temporal);
ZoneOffset offset = ZoneOffset.from(temporal); try { LocalDateTime ldt = LocalDateTime.from(temporal);