Java Code Examples for java.time.Instant.plusNanos()

The following are Jave code examples for showing how to use plusNanos() of the java.time.Instant class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusNanos")
public void plusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds, nanos);
    t = t.plusNanos(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 2
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusNanos")
public void plusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds, nanos);
    t = t.plusNanos(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 3
Project: pure-bliss-with-pure-java-functions   File: OfflineDevicesJobTests.java   Source Code and License Vote up 5 votes
@Test(expected = IllegalArgumentException.class)
public void thatCalculateLastPassedThresholdThrowsExceptionWhenThresholdsAreEmpty() {
    Instant start = Instant.now();
    Instant current = start.plusNanos(1);
    List<Duration> thresholds = Collections.emptyList();

    OfflineDevicesJobImpl.calculateLastPassedThreshold(start, current, thresholds);
}
 
Example 4
Project: pure-bliss-with-pure-java-functions   File: OfflineDevicesJobTests.java   Source Code and License Vote up 5 votes
@Test(expected = IllegalArgumentException.class)
public void thatCalculateLastPassedThresholdThrowsExceptionWhenThresholdsAreEmpty() {
    Instant start = Instant.now();
    Instant current = start.plusNanos(1);
    List<Duration> thresholds = Collections.emptyList();

    OfflineDevicesJobImpl.calculateLastPassedThreshold(start, current, thresholds);
}
 
Example 5
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusNanos_long_overflowTooBig() {
    Instant t = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    t.plusNanos(1);
}
 
Example 6
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusNanos_long_overflowTooSmall() {
    Instant t = Instant.ofEpochSecond(MIN_SECOND, 0);
    t.plusNanos(-1);
}
 
Example 7
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusNanos_long_overflowTooBig() {
    Instant t = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    t.plusNanos(1);
}
 
Example 8
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusNanos_long_overflowTooSmall() {
    Instant t = Instant.ofEpochSecond(MIN_SECOND, 0);
    t.plusNanos(-1);
}