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

The following are Jave code examples for showing how to use plusMillis() 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: pgcodekeeper   File: TimestampPgData.java   Source Code and License Vote up 5 votes
@Override
public Instant generateValue() {
    switch (generator) {
    case CONSTANT: return start;
    case INCREMENT:
        Instant current = currentInc;
        currentInc = current.plusMillis(step.toEpochMilli());
        return current;
    case RANDOM: return generateRandom();
    default:
        return null;
    }
}
 
Example 2
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusMillis")
public void plusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds, nanos);
    t = t.plusMillis(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 3
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusMillis")
public void plusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds + 1, nanos);
    t = t.plusMillis(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds + 1);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 4
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusMillis")
public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds - 1, nanos);
    t = t.plusMillis(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds - 1);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 5
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test
public void plusMillis_long_max() {
    Instant t = Instant.ofEpochSecond(MAX_SECOND, 998999999);
    t = t.plusMillis(1);
    assertEquals(t.getEpochSecond(), MAX_SECOND);
    assertEquals(t.getNano(), 999999999);
}
 
Example 6
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test
public void plusMillis_long_min() {
    Instant t = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    t = t.plusMillis(-1);
    assertEquals(t.getEpochSecond(), MIN_SECOND);
    assertEquals(t.getNano(), 0);
}
 
Example 7
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusMillis")
public void plusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds, nanos);
    t = t.plusMillis(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 8
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusMillis")
public void plusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds + 1, nanos);
    t = t.plusMillis(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds + 1);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 9
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test(dataProvider="PlusMillis")
public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds - 1, nanos);
    t = t.plusMillis(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds - 1);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
Example 10
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test
public void plusMillis_long_max() {
    Instant t = Instant.ofEpochSecond(MAX_SECOND, 998999999);
    t = t.plusMillis(1);
    assertEquals(t.getEpochSecond(), MAX_SECOND);
    assertEquals(t.getNano(), 999999999);
}
 
Example 11
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 5 votes
@Test
public void plusMillis_long_min() {
    Instant t = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    t = t.plusMillis(-1);
    assertEquals(t.getEpochSecond(), MIN_SECOND);
    assertEquals(t.getNano(), 0);
}
 
Example 12
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusMillis_long_overflowTooBig() {
    Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000);
    t.plusMillis(1);
}
 
Example 13
Project: jdk8u-jdk   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusMillis_long_overflowTooSmall() {
    Instant t = Instant.ofEpochSecond(MIN_SECOND, 0);
    t.plusMillis(-1);
}
 
Example 14
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusMillis_long_overflowTooBig() {
    Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000);
    t.plusMillis(1);
}
 
Example 15
Project: openjdk-jdk10   File: TCKInstant.java   Source Code and License Vote up 4 votes
@Test(expectedExceptions=DateTimeException.class)
public void plusMillis_long_overflowTooSmall() {
    Instant t = Instant.ofEpochSecond(MIN_SECOND, 0);
    t.plusMillis(-1);
}