We would like to know how to get the seconds, Minutes between two Instant.
import java.time.Duration; import java.time.Instant; // w w w .j a v a 2 s .c om public class Main { 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); long seconds = between.getSeconds(); long absoluteResult = between.abs().toMinutes(); } }
The code above generates the following result.