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

The following examples show how to use java.time.Instant#minusNanos() . 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
Source File: TCKInstant.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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
Source File: TCKInstant.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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
Source File: TCKInstant.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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
Source File: TCKInstant.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 5
Source File: TestGetStream.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 6
Source File: SecondsIntervalSchedulerFactory.java    From digdag with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: TCKInstant.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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
Source File: TCKInstant.java    From jdk8u-jdk with 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 9
Source File: TCKInstant.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 10
Source File: TCKInstant.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 11
Source File: TCKInstant.java    From openjdk-jdk8u-backup with 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 12
Source File: TCKInstant.java    From openjdk-8 with 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 13
Source File: TCKInstant.java    From openjdk-jdk8u with 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 14
Source File: TCKInstant.java    From hottub with 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 File: TCKInstant.java    From jdk8u60 with 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
Source File: TCKInstant.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 17
Source File: TCKInstant.java    From TencentKona-8 with 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 18
Source File: TCKInstant.java    From j2objc with 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 19
Source File: TCKInstant.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void minusNanos_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusNanos(1);
}
 
Example 20
Source File: TCKInstant.java    From dragonwell8_jdk with 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);
}