Compare date time using before method of Calendar - Java Date Time

Java examples for Date Time:Calendar

Description

Compare date time using before method of Calendar

Demo Code


import java.util.Calendar;
 
public class Main {
 
  public static void main(String[] args) {
    Calendar old = Calendar.getInstance();
   //from  w  w  w  .  j  av  a 2 s  .co  m
    old.set(Calendar.YEAR, 1990);
   
    Calendar now = Calendar.getInstance();
     
    System.out.println("Is old before now ? : " + old.before(now));
  }
}

Result


Related Tutorials