1

I have two DateTime variables: DateTime begin, DateTime end, now I want to "walk trough" the period between these dates and determine date by date if that specific date is a monday, tuesday, etc... (Giving the days a number from 1 to 7).

I can't seen to figure out how to walk through the period date by date...

Thanks in advance.

4

2 回答 2

2

类似的东西;

for (DateTime current = begin; current.isBefore(end); current = current.plusDays(1)) {
    // do stuff
}
于 2013-03-07T15:36:01.290 回答
1

我猜这应该可行

    ArrayList<Integer> days = new Arraylist<Integer>();
    while(begin.isBefore(end)){
        days.add(begin.getDayOfWeek());
        begin.plusDays(1);
    }
于 2013-03-07T15:35:41.840 回答