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

The following examples show how to use java.time.Instant#minusMillis() . 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
public void minusMillis_long_max() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 998999999);
    i = i.minusMillis(-1);
    assertEquals(i.getEpochSecond(), MAX_SECOND);
    assertEquals(i.getNano(), 999999999);
}
 
Example 2
@Test(dataProvider="MinusMillis")
public void minusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds - 1, nanos);
    i = i.minusMillis(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds - 1);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 3
@Test
public void minusMillis_long_max() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 998999999);
    i = i.minusMillis(-1);
    assertEquals(i.getEpochSecond(), MAX_SECOND);
    assertEquals(i.getNano(), 999999999);
}
 
Example 4
@Test
public void minusMillis_long_min() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    i = i.minusMillis(1);
    assertEquals(i.getEpochSecond(), MIN_SECOND);
    assertEquals(i.getNano(), 0);
}
 
Example 5
@Test
public void minusMillis_long_min() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    i = i.minusMillis(1);
    assertEquals(i.getEpochSecond(), MIN_SECOND);
    assertEquals(i.getNano(), 0);
}
 
Example 6
Source Project: j2objc   File: TCKInstant.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void minusMillis_long_min() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    i = i.minusMillis(1);
    assertEquals(i.getEpochSecond(), MIN_SECOND);
    assertEquals(i.getNano(), 0);
}
 
Example 7
@Test(dataProvider="MinusMillis")
public void minusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds + 1, nanos);
    i = i.minusMillis(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds + 1);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 8
@Test(dataProvider="MinusMillis")
public void minusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds - 1, nanos);
    i = i.minusMillis(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds - 1);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 9
@Test(dataProvider="MinusMillis")
public void minusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds + 1, nanos);
    i = i.minusMillis(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds + 1);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 10
@Test
public void minusMillis_long_min() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    i = i.minusMillis(1);
    assertEquals(i.getEpochSecond(), MIN_SECOND);
    assertEquals(i.getNano(), 0);
}
 
Example 11
@Test(dataProvider="MinusMillis")
public void minusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds - 1, nanos);
    i = i.minusMillis(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds - 1);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 12
@Test
public void minusMillis_long_max() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 998999999);
    i = i.minusMillis(-1);
    assertEquals(i.getEpochSecond(), MAX_SECOND);
    assertEquals(i.getNano(), 999999999);
}
 
Example 13
private Optional<Veto> getMesosMaintenanceVeto(Optional<Instant> unavailabilityStart) {
  if (unavailabilityStart.isPresent()) {
    Instant start = unavailabilityStart.get();
    Instant drainTime = start.minusMillis(unavailabilityThreshold.as(Time.MILLISECONDS));

    if (clock.nowInstant().isAfter(drainTime)) {
      return Optional.of(Veto.maintenance(DRAINING.toString().toLowerCase()));
    }
  }
  return Optional.empty();
}
 
Example 14
Source Project: jdk8u60   File: TCKInstant.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="MinusMillis")
public void minusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds - 1, nanos);
    i = i.minusMillis(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds - 1);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
 
Example 15
@Test
public void minusMillis_long_min() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    i = i.minusMillis(1);
    assertEquals(i.getEpochSecond(), MIN_SECOND);
    assertEquals(i.getNano(), 0);
}
 
Example 16
@Test
public void minusMillis_long_min() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    i = i.minusMillis(1);
    assertEquals(i.getEpochSecond(), MIN_SECOND);
    assertEquals(i.getNano(), 0);
}
 
Example 17
@Test(expectedExceptions=DateTimeException.class)
public void minusMillis_long_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 0);
    i.minusMillis(1);
}
 
Example 18
Source Project: j2objc   File: TCKInstant.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected=DateTimeException.class)
public void minusMillis_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999000000);
    i.minusMillis(-1);
}
 
Example 19
@Test(expectedExceptions=DateTimeException.class)
public void minusMillis_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999000000);
    i.minusMillis(-1);
}
 
Example 20
@Test(expectedExceptions=DateTimeException.class)
public void minusMillis_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999000000);
    i.minusMillis(-1);
}