fork download
  1. import java.util.*;
  2. import java.text.*;
  3.  
  4. public class CompareDate{
  5. public static void main(String args[]){
  6. Calendar cal = Calendar.getInstance();
  7. Calendar currentcal = Calendar.getInstance();
  8. cal.set(2000, Calendar.JUNE, 29);
  9. currentcal.set(currentcal.get(Calendar.YEAR),
  10. currentcal.get(Calendar.MONTH), currentcal.get(Calendar.DAY_OF_MONTH));
  11. if(cal.before(currentcal))
  12. System.out.print("Current date(" + new SimpleDateFormat("dd/MM/yyyy").
  13. format(currentcal.getTime()) + ") is greater than the given date " + new
  14. SimpleDateFormat("dd/MM/yyyy").format(cal.getTime()));
  15. else if(cal.after(currentcal))
  16. System.out.print("Current date(" + new SimpleDateFormat("dd/MM/yyyy").
  17. format(currentcal.getTime()) + ") is less than the given date " + new
  18. SimpleDateFormat("dd/MM/yyyy").format(cal.getTime()));
  19. else
  20. System.out.print("Both date are equal.");
  21. }
  22. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty