Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

comparing dates  RSS feed

 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!