Joda-Time:获取特定年份的最大周数

如何通过Joda-Time获得特定年份的最大周数?

回答:

new DateTime().withYear(PARTICULAR_YEAR).weekOfWeekyear().getMaximumValue();

@cody评论

两种方法之间的区别 .withWeekOfWeekyear()和.withWeekyear()

new DateTime().withDate(2011, 1, 2);   

2/1/2011 : Sunday, last day of last week of 2010 (27/12/2010 - 2/1/2011)

dayOfWeek : 7

weekOfWeekyear : 52

weekyear : 2010

new DateTime().withDate(2011, 1, 3);

3/1/2011       : Monday, first day of first week of 2011 (3/1/2011 - 9/1/2011)

dayOfWeek : 1

weekOfWeekyear : 1

weekyear : 2011

以上是 Joda-Time:获取特定年份的最大周数 的全部内容, 来源链接: utcz.com/qa/413054.html

回到顶部