Java Instant compare instants before or after
import java.time.Instant; public class Main { public static void main(String[] args) { Instant i1 = Instant.ofEpochSecond(20); Instant i2 = Instant.ofEpochSecond(55); System.out.println("i1:" + i1); System.out.println("i2:" + i2); // Compare instants System.out.println("i1.isBefore(i2):" + i1.isBefore(i2)); System.out.println("i1.isAfter(i2):" + i1.isAfter(i2)); }//w w w. java2 s . co m }