I'm trying an example:
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
String date = "03/09/2010"; //30 days from today
Date usefullDate = df.parse(date);
Calendar todaysDatePlus30Days = Calendar.getInstance();
todaysDatePlus30Days.add(Calendar.DAY_OF_YEAR, 30);
System.out.println ("Compared Value: " +
usefullDate.compareTo(todaysDatePlus30Days.getTime()))
the printed value is -1
. why is it not printing 0
?
I think the problem is that todaysDatePlus30Days.getTime()
is bringing the actual time as well. whereas usefullDate
's time is 00:00:00
.
So next question is how can I just get the date
?