List of usage examples for java.time Duration minus
public Duration minus(Duration duration)
From source file:Main.java
public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON); System.out.println(duration.getSeconds()); duration = duration.minus(duration); System.out.println(duration.getSeconds()); }
From source file:de.lgblaumeiser.ptm.analysis.analyzer.HourComputer.java
private Duration calculateBreaktime(final Duration presence, final Duration worktime) { return presence.minus(worktime); }
From source file:de.lgblaumeiser.ptm.analysis.analyzer.HourComputer.java
private Duration calculateOvertime(final Duration worktime, final LocalDate day) { Duration minutes = worktime; if (isWeekDay(day)) { minutes = minutes.minus(Duration.ofMinutes(480)); // Overtime is time after 8 hours }/* www .j a v a 2 s . c o m*/ return minutes; }
From source file:org.ulyssis.ipp.reader.Reader.java
/** * Run the reader. Reader implements runnable, so that we can * do this in its own thread.//from w w w. ja v a 2 s.c om */ @Override public void run() { LOG.info("Spinning up reader!"); ReaderConfig.Type type = Config.getCurrentConfig().getReader(options.getId()).getType(); if (type == ReaderConfig.Type.LLRP) { initSpeedway(); if (!speedwayInitialized) { shutdownHook(); return; } } else if (type == ReaderConfig.Type.SIMULATOR) { initSimulator(); } Thread commandThread = new Thread(commandProcessor); commandThread.start(); statusReporter.broadcast(new StatusMessage(StatusMessage.MessageType.STARTED_UP, String.format("Started up reader %s!", options.getId()))); try { while (!Thread.currentThread().isInterrupted()) { Duration maxUpdateInterval = Duration.ofMillis(Config.getCurrentConfig().getMaxUpdateInterval()); if (maxUpdateInterval.minus(Duration.between(lastUpdate, Instant.now())).isNegative()) { lastUpdate = Instant.now(); LOG.warn("No update received in {} seconds!", maxUpdateInterval.getSeconds()); statusReporter.broadcast(new StatusMessage(StatusMessage.MessageType.NO_UPDATES, String.format("No update received in %s seconds!", maxUpdateInterval.getSeconds()))); } Thread.sleep(1000L); } } catch (InterruptedException e) { // We don't care about this exception } commandProcessor.stop(); commandThread.interrupt(); try { commandThread.join(); } catch (InterruptedException ignored) { } shutdownHook(); }