var d1 = new Date();
var d2 = new Date(System.currentTimeMillis() + 1000);
System.out.println(d1);
System.out.println(d2);
System.out.println(d1.compareTo(d2));
System.out.println(d1.before(d2));
System.out.println(d1.getTime()/1000);
output:
Thu Jul 25 17:07:34 CST 2019 Thu Jul 25 17:07:35 CST 2019 -1 true 1564045654