List of usage examples for java.time ZonedDateTime minusHours
public ZonedDateTime minusHours(long hours)
From source file:Main.java
public static void main(String[] args) { ZonedDateTime dateTime = ZonedDateTime.now(); ZonedDateTime n = dateTime.minusHours(1234); System.out.println(n);/*from ww w . j av a 2 s. c o m*/ }
From source file:com.teradata.benchto.service.CleanerService.java
@Transactional @Scheduled(fixedDelay = 1000 * 60 * 60)//from ww w . ja v a 2 s . co m public void cleanUpStaleBenchmarks() { LOG.info("Cleaning up stale benchmarks"); ZonedDateTime currentDate = currentDateTime(); ZonedDateTime startDate = currentDate.minusHours(BENCHMARK_TIMEOUT_HOURS); for (BenchmarkRun benchmarkRun : benchmarkRunRepo.findStartedBefore(startDate)) { LOG.info("Failing stale benchmark - {}", benchmarkRun); benchmarkRun.setEnded(currentDate); benchmarkRun.setStatus(FAILED); benchmarkRunRepo.save(benchmarkRun); } }
From source file:com.teradata.benchto.service.CleanerServiceTest.java
@Test public void cleanUpStaleBenchmarks() throws Exception { Environment environment = new Environment(); environmentRepo.save(environment);/*from ww w. jav a 2s.co m*/ ZonedDateTime currentDate = currentDateTime(); BenchmarkRun staleBenchmark = new BenchmarkRun("stale benchmark test", SEQUENCE_ID, ImmutableMap.of(), UNIQUE_NAME); staleBenchmark.setStatus(STARTED); staleBenchmark.setStarted(currentDate.minusHours(BENCHMARK_TIMEOUT_HOURS).minusMinutes(1)); staleBenchmark.setEnvironment(environment); benchmarkRunRepo.save(staleBenchmark); cleanerService.cleanUpStaleBenchmarks(); BenchmarkRun benchmarkRun = benchmarkRunRepo.findByUniqueNameAndSequenceId(UNIQUE_NAME, SEQUENCE_ID); assertThat(benchmarkRun.getStatus()).isEqualTo(FAILED); assertThat(benchmarkRun.getEnded()).isAfter(currentDate); }