Java Calendar is reduced by default. If you install it before January 32, it will translate it by February 1. In addition, the definition of "week" is local and a bit confusing. This is explained in detail in the JavaDocs associated with the above.
In your particular case (or at least in my Locale) the week is defined as the start on Sunday, and the βfirst week of Juneβ is defined as the period from Sunday to Saturday, which includes June 1, June 1, 2013, this is Saturday, last day of the week 22 2013. Sunday, June 2, 2013, is the first day of the week of June 2, and not the second day of the week.
Since there is no Thursday in the week of June 1, the soft calendar interprets DAY_OF_WEEK, THURSDAY as the Thursday of the week of year 22 of 2013, which is May 30, 2013, which is the week of May 5, so you get 5 and not 1 at your exit.
To set the first Thursday of June, you want:
Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, Calendar.JUNE); calendar.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); calendar.set(Calendar.DAY_OF_WEEK_IN_MONTH, 1);
DAY_OF_WEEK_IN_MONTH can be a little confusing. You use it with DAY_OF_WEEK to indicate which appearance of this day in this month you want. Therefore, when DAY_OF_WEEK set on Thursday, DAY_OF_WEEK_IN_MONTH, 1 is the first Thursday of the month, DAY_OF_WEEK_IN_MONTH, 2 is the second Thursday of the month, etc. This is much less than a local or open (erroneous) interpretation, and then the days make up the first week of the month.