This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

checking for a range of dates

 
Adam Confino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the Calendar class.
 
Tom Johnson
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Adam Confino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good catch. Thanks for saving me some frustration!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic