List of usage examples for java.time Duration between
public static Duration between(Temporal startInclusive, Temporal endExclusive)
From source file:Main.java
public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON); System.out.println(duration.get(ChronoUnit.SECONDS)); }
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.plus(4, ChronoUnit.DAYS); System.out.println(duration.getSeconds()); }
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(3, ChronoUnit.DAYS); System.out.println(duration.getSeconds()); }
From source file:Main.java
public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON); List<TemporalUnit> l = duration.getUnits(); for (TemporalUnit u : l) { System.out.println(u);//from w ww . j a va2s . c om } }
From source file:Main.java
public static void main(String[] args) { Instant t1 = Instant.now(); Instant t2 = Instant.now().plusSeconds(12); long nanos = Duration.between(t1, t2).toNanos(); System.out.println(nanos);/*from w w w. ja v a2 s . c o m*/ Duration gap = Duration.ofSeconds(13); // 12000000000 Instant later = t1.plus(gap); System.out.println(t1); // 2014-07-02T19:55:00.956Z System.out.println(later); // 2014-07-02T19:55:13.956Z System.out.println(ChronoUnit.MILLIS.between(t1, t2)); // 12000 }
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);//from w w w .ja v a 2 s . c o m }
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);/*from w w w .j a v a 2 s. c o m*/ long seconds = between.getSeconds(); long absoluteResult = between.abs().toMinutes(); }
From source file:Main.java
public static void main(String[] argv) { ZonedDateTime here = ZonedDateTime.now(ZoneId.of("America/Los_Angeles")); ZonedDateTime gmtNewYear = ZonedDateTime.of(2014, 12, 31, 23, 59, 59, 0, ZoneId.of("Europe/London")); Duration d = Duration.between(here, gmtNewYear); System.out.println(d);//from w w w. ja va2 s . c o m }
From source file:Main.java
public static void main(String[] args) { Instant t1 = Instant.now(); long hours = 2; long minutes = 30; Instant t2 = t1.plus(hours, ChronoUnit.HOURS).plus(minutes, ChronoUnit.MINUTES); long minutesBetween = Duration.between(t1, t2).toMinutes(); System.out.println(minutesBetween); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime l = LocalDateTime.of(2012, Month.AUGUST, 13, 0, 0, 0); ZonedDateTime z = ZonedDateTime.of(LocalDateTime.of(2014, Month.AUGUST, 13, 0, 0, 0), ZoneId.of("America/Los_Angeles")); Duration duration = Duration.between(l, z); System.out.println(duration); }