views:

84

answers:

3

What is the best practice to iterate through a start and end date?

+2  A: 

I once used a variant of the following Date Iterator.

Not sure if it is a best practice or not, but it was a clear solution and I liked it.

dpb
A: 

Iterator myVeryOwnIterator = HashMap.keySet().iterator(); while(myVeryOwnIterator.hasNext()) { System.out.println(myVeryOwnIterator.next()); }

salyutan
A: 

If you want to iterate between certain time units such as every hour between two dates, you could take a look at this obligatory joda-time answer: Java date iterator factory, with rules specifying how to calculate the intervals

Esko