Compare date time using before method of Calendar in Java
Description
The following code shows how to compare date time using before method of Calendar.
Example
// www . j a v a 2 s . c om
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
Calendar old = Calendar.getInstance();
old.set(Calendar.YEAR, 2990);
Calendar now = Calendar.getInstance();
System.out.println("Is old before now ? : " + old.before(now));
}
}
The code above generates the following result.