Saturday, April 6, 2002 09:31 PM
A Date object is actually a time representation.
As stated in the JavaDoc:
The class Date represents a specific instant in time, with millisecond precision.
java.util.Calendar and java.util.GregorianCalendar
are much more adept at handling and manipulating dates.
Here is a simple example of comparing 2 like dates using GregorianCalendar:
//set both calendarA and calendarB to the date:
//April 6th, 2002
Calendar calendarA = new GregorianCalendar(2002,4,6);
Calendar calendarB = new GregorianCalendar(2002,4,6);
System.out.println("Yup..they are equal!");
Also take a look at SimpleDateFormat for a nice way to format output of Calendar objects.