| Author |
How to validate a date greater than current date
|
rahulJ james
Ranch Hand
Joined: Oct 03, 2008
Posts: 123
|
|
I wanted to validate a date which should not be more than the current date. Any idea as I dont get any clue on this.
I am using the format
DateFormat objDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
 |
Eric Bruno
author
Ranch Hand
Joined: Jun 15, 2009
Posts: 60
|
|
|
You can use the Date.compareTo method. It takes an argument Date, and returns the value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument. It's in the Java docs also.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
And if you want date comparison (as in: today, tomorrow etc) just do a search. The question on how to calculate the difference in days between to Date objects has been asked numerous times before.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: How to validate a date greater than current date
|
|
|