【发布时间】:2014-12-30 06:35:27
【问题描述】:
我实际上正在使用实用程序类 Calender。 我发现自己很困惑,
方法
getFirstDayOfWeek()
returns the first day of the week;
e.g., SUNDAY in the U.S., MONDAY in France.
和
getMinimalDaysInFirstWeek()
returns the minimal days required in the first week of the year. e.g.,
if the first week is defined as one that contains the first day of the
first month of a year, this method returns 1. If the minimal days required
must be a full week, this method returns 7.
我住在印度 (UTC+05:30) 钦奈、加尔各答、孟买、新德里。 该时区不实行夏令时。
为了获得一年中的一周,我这样编码
Calendar calendar = Calendar.getInstance();
System.out.println(calendar.get(Calendar.WEEK_OF_YEAR)); // returns 45
45 只有在 Java 处理
时才有可能WeekNumber FromDate ToDate
Week 01 December 30, 2013 January 5, 2014 // December 30 is Monday
Week 45 November 3, 2014(Monday) November 9, 2014
Java 需要最少几天才能变成一个完整的一周变成 7 天吗?因为我可以通过 setMinimalDaysInFirstWeek() 来改变它。又会有什么影响?
【问题讨论】:
标签: java calendar java.util.calendar