分享

setFirstDayOfWeek无效

 hh3755 2015-01-22

我发现使用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.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多