Java Code Examples for org.threeten.bp.Instant#from()

The following examples show how to use org.threeten.bp.Instant#from() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Chronology.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Obtains a zoned date-time in this chronology from another temporal object.
 * <p>
 * This creates a date-time in this chronology based on the specified {@code TemporalAccessor}.
 * <p>
 * This should obtain a {@code ZoneId} using {@link ZoneId#from(TemporalAccessor)}.
 * The date-time should be obtained by obtaining an {@code Instant}.
 * If that fails, the local date-time should be used.
 *
 * @param temporal  the temporal object to convert, not null
 * @return the zoned date-time in this chronology, not null
 * @throws DateTimeException if unable to create the date-time
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public ChronoZonedDateTime<?> zonedDateTime(TemporalAccessor temporal) {
    try {
        ZoneId zone = ZoneId.from(temporal);
        try {
            Instant instant = Instant.from(temporal);
            return zonedDateTime(instant, zone);

        } catch (DateTimeException ex1) {
            ChronoLocalDateTime cldt = localDateTime(temporal);
            ChronoLocalDateTimeImpl cldtImpl = ensureChronoLocalDateTime(cldt);
            return ChronoZonedDateTimeImpl.ofBest(cldtImpl, zone, null);
        }
    } catch (DateTimeException ex) {
        throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
    }
}
 
Example 2
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 3
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 4
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 5
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 6
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 7
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 8
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 9
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 10
Source File: CustomInstantDeserializer.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}
 
Example 11
Source File: CustomInstantDeserializer.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
}