The first thing to understand is that Month + Day + DayOfWeek means nothing to the Calendar. The calendar will calculate the true date value based on
YEAR + MONTH + DATE
or
YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
(Or some other combos, such as year + day of the year, etc.). So Date + DayOfWeek doesn't really matter to him.
The second thing you need to understand is when you install the Java calendar, it does not actually recalculate the absolute time or the fields associated with the update until an operation occurs that forces the calculation.
After your first set, the calendar is in a conflicting state. The month and day say it is July 12th, but the "week of the month" and "day of the week" still say that today, regardless of today. Then you call the set day of the week on Friday. So now the year month and day say July 12th, but the "week of the month" and "day of the week" fields talk about Friday of the week 'this'.
The rules of the calendar say that the last specified field โwinsโ when there is a conflict, so the week of the month and day of the week, combined with the expression on Friday this week, is used to calculate other fields.
Inserting get in the middle โcorrectsโ it, because it causes the entire internal state of the calendar to be redistributed on Tuesday July 12th before installation on Friday, so there are no internal conflicts. "Week of the month" was set to week, which contains July 12 by recounting before you set the day of the week to Friday.
Edit: sorry for making the changes in two days, noticing that it is open on the old browser tab, and I thought that I would expand for reliable help of future googlers:
The reason she worked for John in the comments is because he lives in London. His computer thinks weeks start on Mondays. Therefore, when asked on Friday the week of 'this', he still answered on July 15 when he was asked on Sunday, July 17. I talk about this because the excellent first days of the week in different locales are another way that trying to use the WEEK_OF fields in a calendar converges.
Affe Jul 17 '11 at 8:00 2011-07-17 08:00
source share