本文整理汇总了Java中java.time.Instant.parse方法的典型用法代码示例。如果您正苦于以下问题:Java Instant.parse方法的具体用法?Java Instant.parse怎么用?Java Instant.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.Instant
的用法示例。
在下文中一共展示了Instant.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: thatPushNotificationIsSentWhenLastThresholdWasPassedAndLastSentNotificationWasForPreviousThreshold
import java.time.Instant; //导入方法依赖的package包/类
@Test
public void thatPushNotificationIsSentWhenLastThresholdWasPassedAndLastSentNotificationWasForPreviousThreshold() throws Exception {
Duration firstThreshold = Duration.ofDays(1);
Duration secondThreshold = Duration.ofDays(2);
Instant disconnectInstant = Instant.parse("2010-10-10T10:10:00.00Z");
Instant lastOfflineNotificationInstant = disconnectInstant.plus(firstThreshold).plusSeconds(1);
Instant jobRunInstant = disconnectInstant.plus(secondThreshold).plusSeconds(1);
when(pushNotificationService.getLastOfflineNotificationInstant(any(Device.class))).thenReturn(Optional.of(lastOfflineNotificationInstant));
when(clock.instant()).thenReturn(disconnectInstant);
offlineDevicesJob.onConfigurationUpdate(Arrays.asList(firstThreshold, secondThreshold));
offlineDevicesJob.onDeviceDisconnect(new Device(UUID.randomUUID()));
when(clock.instant()).thenReturn(jobRunInstant);
offlineDevicesJob.run();
verify(pushNotificationService, times(1)).sendOfflineNotification(any(Device.class));
}
开发者ID:pietvandongen,项目名称:pure-bliss-with-pure-java-functions,代码行数:22,代码来源:OfflineDevicesJobTests.java
示例2: thatPushNotificationIsSentWhenThresholdWasPassedAndNoNotificationWasEverSent
import java.time.Instant; //导入方法依赖的package包/类
@Test
public void thatPushNotificationIsSentWhenThresholdWasPassedAndNoNotificationWasEverSent() throws Exception {
Duration firstThreshold = Duration.ofDays(1);
Duration secondThreshold = Duration.ofDays(2);
Instant disconnectInstant = Instant.parse("2010-10-10T10:10:00.00Z");
Instant jobRunInstant = disconnectInstant.plus(firstThreshold).plusSeconds(1);
when(pushNotificationService.getLastOfflineNotificationInstant(any(Device.class))).thenReturn(Optional.empty());
when(clock.instant()).thenReturn(disconnectInstant);
offlineDevicesJob.onConfigurationUpdate(Arrays.asList(firstThreshold, secondThreshold));
offlineDevicesJob.onDeviceDisconnect(new Device(UUID.randomUUID()));
when(clock.instant()).thenReturn(jobRunInstant);
offlineDevicesJob.run();
verify(pushNotificationService, times(1)).sendOfflineNotification(any(Device.class));
}
开发者ID:pietvandongen,项目名称:pure-bliss-with-pure-java-functions,代码行数:21,代码来源:OfflineDevicesJobTests.java
示例3: testConstructionOfInput
import java.time.Instant; //导入方法依赖的package包/类
@Test
public void testConstructionOfInput() {
final Instant evaluationTime = Instant.parse("2013-03-28T00:00:00Z");
final Input input = Input.create("TestRuleSetName",
DecisionTreeRuleSet.convertNamesToWeightedDrivers(Arrays.asList("driver1", "driver2")),
evaluationTime);
assertEquals("TestRuleSetName", input.getRuleSetName());
assertEquals("*", input.getValueForDriverName("driver1"));
assertEquals("*", input.getValueForDriverName("driver2"));
assertEquals(evaluationTime, input.getEvaluationDate());
assertEquals(Arrays.asList("*", "*"), input.getEvaluationInputs());
assertEquals("Input{driverMap={WeightedDriver{name='driver1', weight=4}=*, " +
"WeightedDriver{name='driver2', weight=2}=*}, " +
"ruleSetName='TestRuleSetName', " +
"evaluationDate=2013-03-28T00:00:00Z}", input.toString());
}
示例4: deserialze
import java.time.Instant; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == 4) {
String text = lexer.stringVal();
lexer.nextToken();
if (type == LocalDateTime.class) {
return LocalDateTime.parse(text);
}
if (type == LocalDate.class) {
return LocalDate.parse(text);
}
if (type == LocalTime.class) {
return LocalTime.parse(text);
}
if (type == ZonedDateTime.class) {
return ZonedDateTime.parse(text);
}
if (type == OffsetDateTime.class) {
return OffsetDateTime.parse(text);
}
if (type == OffsetTime.class) {
return OffsetTime.parse(text);
}
if (type == ZoneId.class) {
return ZoneId.of(text);
}
if (type == Period.class) {
return Period.parse(text);
}
if (type == Duration.class) {
return Duration.parse(text);
}
if (type == Instant.class) {
return Instant.parse(text);
}
return null;
}
throw new UnsupportedOperationException();
}
示例5: ensureValid
import java.time.Instant; //导入方法依赖的package包/类
@Override
public void ensureValid(String name, Object value) {
String timestamp = (String) value;
try {
Instant.parse(timestamp);
} catch (DateTimeParseException e) {
throw new ConfigException(name, value, "Wasn't able to parse the timestamp, make sure it is formatted according to ISO-8601 standards");
}
}
示例6: stringToInstant
import java.time.Instant; //导入方法依赖的package包/类
public static final Instant stringToInstant(String text) {
try {
return Instant.parse(text);
} catch (Exception ex) {
try {
return Instant.ofEpochMilli(Long.parseLong(text));
} catch (Exception ex2) {
try {
return Timestamp.valueOf(text).toInstant();
} catch (Exception ex3) {
return null;
}
}
}
}
示例7: createAnItemEvictedEvent
import java.time.Instant; //导入方法依赖的package包/类
@Test
public void createAnItemEvictedEvent() throws Exception {
Instant fixedInstant = Instant.parse("2017-04-07T10:02:05.456Z");
Clock clock = Clock.fixed(fixedInstant, ZoneId.of("+02:00"));
Item item = anItem().withName("item name").build();
Event<Item> event = new SimpleEventFactory(clock).newItemEvictedEvent(item);
assertThat(event.created(), is(fixedInstant));
assertThat(event.body(), is(item));
}
示例8: createAnItemStoredEvent
import java.time.Instant; //导入方法依赖的package包/类
@Test
public void createAnItemStoredEvent() throws Exception {
Instant fixedInstant = Instant.parse("2017-03-21T22:35:18.123Z");
Clock clock = Clock.fixed(fixedInstant, ZoneId.of("+01:00"));
Item item = anItem().withName("item name").build();
Event<Item> event = new SimpleEventFactory(clock).newItemStoredEvent(item);
assertThat(event.created(), is(fixedInstant));
assertThat(event.body(), is(item));
}
示例9: CoffeeBrewFinished
import java.time.Instant; //导入方法依赖的package包/类
public CoffeeBrewFinished(JsonObject jsonObject) {
this(UUID.fromString(jsonObject.getString("orderId")), Instant.parse(jsonObject.getString("instant")));
}
示例10: setStartDate
import java.time.Instant; //导入方法依赖的package包/类
public void setStartDate(String startDate) {
if (StringUtils.isNotBlank(startDate)) {
this.startDate = Instant.parse(startDate);
}
}
示例11: CoffeeBrewStarted
import java.time.Instant; //导入方法依赖的package包/类
public CoffeeBrewStarted(JsonObject jsonObject) {
this(new OrderInfo(jsonObject.getJsonObject("orderInfo")), Instant.parse(jsonObject.getString("instant")));
}
示例12: OrderFinished
import java.time.Instant; //导入方法依赖的package包/类
public OrderFinished(JsonObject jsonObject) {
this(UUID.fromString(jsonObject.getString("orderId")), Instant.parse(jsonObject.getString("instant")));
}
示例13: createdDateProvider
import java.time.Instant; //导入方法依赖的package包/类
private static Stream<Instant> createdDateProvider() {
Instant firstDateInstant = Instant.parse("2017-01-01T08:00:00.846Z");
Instant secondDateInstant = Instant.parse("2018-01-01T08:00:00.846Z");
return Stream.of(firstDateInstant, secondDateInstant);
}
示例14: OrderAccepted
import java.time.Instant; //导入方法依赖的package包/类
public OrderAccepted(JsonObject jsonObject) {
this(new OrderInfo(jsonObject.getJsonObject("orderInfo")), Instant.parse(jsonObject.getString("instant")));
}
示例15: OrderBeansValidated
import java.time.Instant; //导入方法依赖的package包/类
public OrderBeansValidated(JsonObject jsonObject) {
this(UUID.fromString(jsonObject.getString("orderId")), Instant.parse(jsonObject.getString("instant")));
}