Android Calendar problem with day of the week
<p>I'm trying to list all days of the week for current week from Monday to Sunday. For example, today (day of this posting) is September 4th, 2011 and it's Sunday.</p>

<p>I'm starting calendar and setting first day of the week to Monday:</p>

<pre><code>Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);
</code></pre>

<p>When I check day of the month, I get correct result:</p>

<pre><code>int check = cal.get(Calendar.DAY_OF_MONTH);
// check is equal to 4
</code></pre>

<p>But when I set weekday to Monday, it jumps to the next week instead of returning Monday of this week:</p>

<pre><code>cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
int mon = cal.get(Calendar.DAY_OF_MONTH);
// mon is equal to 5, when expected to be 29 (last Monday of August)
</code></pre>

<p>Even setting weekday to Sunday returns next Sunday and not today.</p>

<p>Can someone explain why it works that way and what's the best way to solve this problem?</p>
