Compare two Date objects using before method in Java
Description
The following code shows how to compare two Date objects using before method.
Example
/* w w w . j a v a 2s . c om*/
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 first date before second ? : " + d1.before(d2));
}
}
The code above generates the following result.