java Compare two dates

The Solution to java Compare two dates is


java.util.Date class has before and after method to compare dates.

Date date1 = new Date();
Date date2 = new Date();

if(date1.before(date2)){
    //Do Something
}

if(date1.after(date2)){
    //Do Something else
}

~ Answered on 2013-04-10 12:17:18


Most Viewed Questions: