jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes checking for a range of dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "checking for a range of dates" Watch "checking for a range of dates" New topic

checking for a range of dates

Adam Confino
Ranch Hand

Joined: Sep 03, 2009
Posts: 48
Hey Java Gurus! I need help thinking through the programming logic for a method.

Lets say I have a HotelRoom object that has two Strings - CheckIn "Jan-01-10" and CheckOut - "Jan-05-10".
I would like to write a method that could take those two Strings and check for the range of dates.

I'll post the method I have to check for a single date. How would I check for a range?

As always...thanks so much for your valuable time.

Just Another Guy Hooked on Java
David Newton

Joined: Sep 29, 2008
Posts: 12617

Check the Calendar class.
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
As an aside, you should create a new SimpleDateFomat an not parse date "one" inside the for loop. The value will remain the same each time so you should move it to the start of the method and reuse the result i.e.

<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
Adam Confino
Ranch Hand

Joined: Sep 03, 2009
Posts: 48
Good catch. Thanks for saving me some frustration!
I agree. Here's the link: http://aspose.com/file-tools
subject: checking for a range of dates
It's not a secret anymore!