File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes comparing dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "comparing dates" Watch "comparing dates" New topic
Author

comparing dates

Patrick Mallahan
Ranch Hand

Joined: Apr 22, 2005
Posts: 69
how can I compare two dates one being a java.sql.Date and the other being a Calendar? I need to do a while date1<=date2.
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
Originally posted by Patrick Mallahan:
how can I compare two dates one being a java.sql.Date and the other being a Calendar? I need to do a while date1<=date2.


Create another Calendar and set its date:

c2.setTime( date );

Now you can compare both using before(), equals(), after():

while( c1.before( c2 ) ) ...
Patrick Mallahan
Ranch Hand

Joined: Apr 22, 2005
Posts: 69
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: comparing dates