Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare dates

Status
Not open for further replies.

Pichdude

Programmer
Aug 24, 2005
66
SE
Hi,

I want to compare a date (that a user inputs) and validate that it is today or later.

I create a Date from what the user inputs, but I want to know how I can compare it with the Date of today. If I user Calendar.getInstance().getTime() I get the exact time of now, e.g. 2006-01-16 13:01:40, but I want to compare it with 2006-01-16 00:00:00 e.g the first second of todays date. How can I perform that?

Best regards
 
To blank out the 'time' portion of today, so this:-

Code:
   Calendar cal = Calendar.getInstance();
   cal.set(Calendar.HOUR_OF_DAY, 0);
   cal.set(Calendar.MINUTE, 0);
   cal.set(Calendar.SECOND, 0);
   cal.set(Calendar.MILLISECOND, 0);

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top