當前位置: 首頁>>代碼示例>>Java>>正文


Java Instant.minusSeconds方法代碼示例

本文整理匯總了Java中java.time.Instant.minusSeconds方法的典型用法代碼示例。如果您正苦於以下問題:Java Instant.minusSeconds方法的具體用法?Java Instant.minusSeconds怎麽用?Java Instant.minusSeconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.Instant的用法示例。


在下文中一共展示了Instant.minusSeconds方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: does_not_skip_newer_events_for_out_of_order_older_events_when_applying_a_delay

import java.time.Instant; //導入方法依賴的package包/類
@Test public void
does_not_skip_newer_events_for_out_of_order_older_events_when_applying_a_delay() throws Exception {
    Instant event1Instant = clock.instant();
    Instant event2Instant = event1Instant.minusSeconds(1L);

    EventReader input = new EventReader() {
        @Override
        public Stream<ResolvedEvent> readAllForwards(Position positionExclusive) {
            return ImmutableList.of(
                    new ResolvedEvent(new Position() { }, eventRecord(event1Instant, streamId("a", "1"), 1L, "X", new byte[0], new byte[0])),
                    new ResolvedEvent(new Position() { }, eventRecord(event2Instant, streamId("b", "1"), 1L, "X", new byte[0], new byte[0]))
            ).stream();
        }

        @Override public Position emptyStorePosition() { return null; }
    };

    EventReader outputReader = MergedEventSource.streamOrderMergedEventSource(clock, ofSeconds(1L), new NamedReaderWithCodec("a", input, JavaInMemoryEventStore.CODEC)).readAll();

    assertThat(outputReader.readAllForwards().count(), is(0L));

    clock.bump(ofSeconds(1L));
    assertThat(outputReader.readAllForwards().count(), is(2L));
}
 
開發者ID:tim-group,項目名稱:tg-eventstore,代碼行數:25,代碼來源:MergedEventSourceTest.java

示例2: minusSeconds_long

import java.time.Instant; //導入方法依賴的package包/類
@Test(dataProvider="MinusSeconds")
public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds, nanos);
    i = i.minusSeconds(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:TCKInstant.java

示例3: minusSeconds_long_overflowTooBig

import java.time.Instant; //導入方法依賴的package包/類
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(1, 0);
    i.minusSeconds(Long.MIN_VALUE + 1);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKInstant.java

示例4: minusSeconds_long_overflowTooSmall

import java.time.Instant; //導入方法依賴的package包/類
@Test(expectedExceptions = {ArithmeticException.class})
public void minusSeconds_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(-2, 0);
    i.minusSeconds(Long.MAX_VALUE);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKInstant.java


注:本文中的java.time.Instant.minusSeconds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。