List of usage examples for java.time Duration abs
public Duration abs()
From source file:Main.java
public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON); System.out.println(duration.abs()); }
From source file:Main.java
public static void main(String[] args) { Instant firstInstant = Instant.ofEpochSecond(1294881180); Instant secondInstant = Instant.ofEpochSecond(1294708260); Duration between = Duration.between(firstInstant, secondInstant); System.out.println(between);/* w w w . ja v a 2 s .co m*/ long seconds = between.getSeconds(); long absoluteResult = between.abs().toMinutes(); }
From source file:nu.yona.server.analysis.service.AnalysisEngineService.java
private Duration determineDeviceTimeOffset(AppActivitiesDto appActivities) { Duration offset = Duration.between(ZonedDateTime.now(), appActivities.getDeviceDateTime()); return (offset.abs().compareTo(DEVICE_TIME_INACCURACY_MARGIN) > 0) ? offset : Duration.ZERO; // Ignore if less than 10 // seconds/*from w w w . j av a 2 s .c o m*/ }