Java Code Examples for java.time.Instant#minusNanos()

The following examples show how to use java.time.Instant#minusNanos() . These examples are extracted from open source projects. 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
@Test(dataProvider="MinusNanos")
public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds, nanos);
    i = i.minusNanos(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 2
@Test(dataProvider="MinusNanos")
public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds, nanos);
    i = i.minusNanos(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 3
@Test(dataProvider="MinusNanos")
public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds, nanos);
    i = i.minusNanos(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 4
@Override
public ScheduleTime lastScheduleTime(Instant currentScheduleTime)
{
    checkArgument(currentScheduleTime.getEpochSecond() > 0);
    currentScheduleTime = currentScheduleTime.minusNanos(1);
    long lastEpoch = currentScheduleTime.getEpochSecond() - (currentScheduleTime.getEpochSecond() % interval);
    Instant last = Instant.ofEpochSecond(lastEpoch);
    return ScheduleTime.of(last, last.plusSeconds(delay));
}
 
Example 5
@Test(dataProvider="MinusNanos")
public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds, nanos);
    i = i.minusNanos(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 6
private static void assertEndBeforeBegin() throws IOException {
    try (Recording recording = new Recording()) {
        recording.start();
        recording.stop();
        Instant begin = Instant.now();
        Instant end = begin.minusNanos(1);
        recording.getStream(begin, end);
        Asserts.fail("Expected IllegalArgumentException has not been thrown");
    } catch (IllegalArgumentException x) {
        // Caught the expected exception
    }
}
 
Example 7
@Test(dataProvider="MinusNanos")
public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds, nanos);
    i = i.minusNanos(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 8
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 9
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 10
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 11
Source Project: j2objc   File: TCKInstant.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 12
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 13
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 14
Source Project: jdk8u60   File: TCKInstant.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 15
Source Project: hottub   File: TCKInstant.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 16
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 17
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 18
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}
 
Example 19
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 20
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.minusNanos(-1);
}