我实际上正在学习实用程序类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
仅当Java对待时才45
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()进行更改。它将产生什么影响?
与一年中一周中的天数有关。除非您对周年感兴趣,否则可能与您无关。默认情况下,我希望它是4,因为这是正常的ISO-8601值。
我不确定这是否与“一周的第一天”部分互动-您需要检查一下,但听起来确实如此。它不应该有任何与你的时区。
但是,例如,2014年从2013年12月30日开始,恰好是因为2014年有5天。如果再看其他年份,您会发现X年1月的前几天在第52周或年份X-1的第53周。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句