Compare Two Dates
7
Compare two dates in Java.
// Compare two dates
public static boolean compareDates(Date dDateA, Date dDateB)
{
// Declare variables
GregorianCalendar cDateA = new GregorianCalendar();
GregorianCalendar cDateB = new GregorianCalendar();
// Set dates
cDateA.setTime(dDateA);
cDateB.setTime(dDateB);
// Compare
if (cDateA.get(Calendar.MONTH) == cDateB.get(Calendar.MONTH) && cDateA.get(Calendar.YEAR) == cDateB.get(Calendar.YEAR) && cDateA.get(Calendar.DAY_OF_MONTH) == cDateB.get(Calendar.DAY_OF_MONTH))
{
return true;
}
return false;
}
Comments
Sat. Jun. 7th, 2008 5:02 PM
me
me
Mon. Apr. 3rd, 2006 10:06 AM
jpinkham
jpinkham





