Java examples for Date Time:Legacy Date
Compare two Date objects using after method
import java.util.Date; public class Main { public static void main(String[] args) { Date d1 = new Date(); try{/*from w w w . j a v a 2 s . c o m*/ Thread.sleep(10); }catch(Exception e){ } Date d2 = new Date(); System.out.println("First Date : " + d1); System.out.println("Second Date : " + d2); System.out.println("Is second date after first ? : " + d2.after(d1)); } }