comparing dates
Is it possible to take two dates and see if one is greater than the other.
I can't seem to find any information on how I would go about doing this.
Maybe my thinking is off but this is what I wanted to try to do:
String d ="2006-04-16';
Date wd = java.sql.Date.valueOf(d);
Date cd =new java.sql.Date(System.currentTimeMillis());
if(wd > cd){
JOptionPane.showMessageDialog(null,"You have entered a future date. \n"+
"Do you really want to do this?");
}else{
//do nothing
}
I'm getting an error saying: (operator > can't be applied to java.sql.Date, java.sql.Date)
I know that using >, <, >=, <= and all are used for comparing numbers.
So how would I go about changing my if statement to work for comparing the dates?
thanks
-PD
[1165 byte] By [
Wh0.M3a] at [2007-10-2 17:39:17]

> Comparison of Date objects is done using the
> before(), after() and equals() methods. Refer to the
> documentation!
Ohhhh.. hmmm.. *eyes glaze over*
I guess i'm just used to being able to use those things with sql statements when looking for dates...
thanks
*thump.. thump... thump*
-PD (<-- hitting head on desk)
well TGIF..
ok so what your saying I should use it more like this:
if(wd.before(cd)) {
JOptionPane.showMessageDialog(null, "You have entered a future date. \n"+
"Do you really want to do this?");
}else{
//do nothing
}
> Ohhhh.. hmmm.. *eyes glaze over*
> I guess i'm just used to being able to use those
> things with sql statements when looking for dates...
>
> thanks
> *thump.. thump... thump*
> -PD (<-- hitting head on desk)
sorry it's been one of those weeks
-PD