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]
# 1
Comparison of Date objects is done using the before(), after() and equals() methods. Refer to the documentation!
aniseeda at 2007-7-13 18:56:36 > top of Java-index,Java Essentials,Java Programming...
# 2
> String d = "2006-04-16';is suppose to readString d = "2006-04-16";missed the shift key..-PD
Wh0.M3a at 2007-7-13 18:56:36 > top of Java-index,Java Essentials,Java Programming...
# 3

> 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)

Wh0.M3a at 2007-7-13 18:56:36 > top of Java-index,Java Essentials,Java Programming...
# 4

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

}

Wh0.M3a at 2007-7-13 18:56:36 > top of Java-index,Java Essentials,Java Programming...
# 5

> 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

Wh0.M3a at 2007-7-13 18:56:36 > top of Java-index,Java Essentials,Java Programming...
# 6
> if(wd.before(cd)) {should be if(wd.after(cd)) {duh... ok thanks for your help-PD(<-- in need of b33r)
Wh0.M3a at 2007-7-13 18:56:36 > top of Java-index,Java Essentials,Java Programming...
# 7
> duh... ok thanks for your help> > -PD(<-- in need of b33r)Good that I could help you. Have fun!
aniseeda at 2007-7-13 18:56:36 > top of Java-index,Java Essentials,Java Programming...