我发现使用setFirstDayOfWeek()修改周的第一天。使用Calendar.get(Calendar.DAY_OF_WEEK)一直不会变。后面网上查了一下资料,好像我们误解了这个方法。 原文:http:///questions/24554241/calendar-not-working-fine I think you've misunderstood the purpose of setFirstDayOfWeek .
That doesn't change c.get(Calendar.DAY_OF_WEEK) works at all - it changes the result of calling c.get(Calendar.WEEK_OF_MONTH) and c.get(Calendar.WEEK_OF_YEAR) , as per the documentation:
When setting or getting the WEEK_OF_MONTH or WEEK_OF_YEAR fields, Calendar must determine the first week of the month or year as a reference point. The first week of a month or year is defined as the earliest seven day period beginning on getFirstDayOfWeek() and containing at least getMinimalDaysInFirstWeek() days of that month or year.
In other words, Sunday is always Sunday... but whether Sunday June 10th is in the same week as Monday June 11th or not depends on what is considered to be the first day of the week.
|