下面列出了java.time.ZoneId#from ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test(groups = { "server-search-all" }, dependsOnMethods = { "testCreatePatient" })
public void testSearchAllUsingLastUpdatedGeLe() throws Exception {
// ge2018-09-01T00:00:00Z&
// le2018-09-01T00:00:00Z&
FHIRParameters parameters = new FHIRParameters();
ZoneId zoneId = ZoneId.from(lastUpdated.getValue());
ZonedDateTime beforeOneHourZdt = ZonedDateTime.ofInstant(lastUpdated.getValue().toInstant().minus(1, ChronoUnit.HOURS),zoneId);
ZonedDateTime afterOneHourZdt = ZonedDateTime.ofInstant(lastUpdated.getValue().toInstant().plus(1, ChronoUnit.HOURS),zoneId);
parameters.searchParam("_lastUpdated", "ge" + beforeOneHourZdt.toString());
parameters.searchParam("_lastUpdated", "le" + afterOneHourZdt.toString());
FHIRResponse response = client.searchAll(parameters, false, headerTenant, headerDataStore);
assertResponse(response.getResponse(), Response.Status.OK.getStatusCode());
Bundle bundle = response.getResource(Bundle.class);
assertNotNull(bundle);
assertTrue(bundle.getEntry().size() >= 1);
}
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
ZoneId.from(null);
}
@Test(expected=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
ZoneId.from(LocalTime.of(12, 30));
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
ZoneId.from(null);
}
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
ZoneId.from(null);
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
ZoneId.from(LocalTime.of(12, 30));
}
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
ZoneId.from(null);
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
ZoneId.from(LocalTime.of(12, 30));
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
ZoneId.from(LocalTime.of(12, 30));
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
ZoneId.from(LocalTime.of(12, 30));
}
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
ZoneId.from(null);
}
/**
* Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object.
* <p>
* This obtains a zoned date-time in this chronology based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code ChronoZonedDateTime}.
* <p>
* The conversion will first obtain a {@code ZoneId} from the temporal object,
* falling back to a {@code ZoneOffset} if necessary. It will then try to obtain
* an {@code Instant}, falling back to a {@code ChronoLocalDateTime} if necessary.
* The result will be either the combination of {@code ZoneId} or {@code ZoneOffset}
* with {@code Instant} or {@code ChronoLocalDateTime}.
* Implementations are permitted to perform optimizations such as accessing
* those fields that are equivalent to the relevant objects.
* The result uses this chronology.
* <p>
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code aChronology::zonedDateTime}.
*
* @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
* @see ChronoZonedDateTime#from(TemporalAccessor)
*/
default ChronoZonedDateTime<? extends ChronoLocalDate> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTimeImpl<?> cldt = ChronoLocalDateTimeImpl.ensureValid(this, localDateTime(temporal));
return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
@Test(expected=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
ZoneId.from(null);
}