Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparing dates

 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic