Compare two Java Date objects using after method in Java
Description
The following code shows how to compare two Java Date objects using after method.
Example
//from w w w .j av a 2s . c o m
import java.util.Date;
public class Main {
public static void main(String[] args) {
Date d1 = new Date();
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));
}
}
The code above generates the following result.