我尝试将某些日期与jodaTime进行比较,我使用星期和年份来比较日期

DateMidnight endDate01 = new DateMidnight().withYear(2012).withWeekyear(37);
DateMidnight endDate02 = new DateMidnight().withYear(2012).withWeekyear(38);


endDate01.isBefore(endDate02); //return false


我不明白为什么endDate01看起来比endDate02大。

也许是个错误?

DateMidnight endDate01 = new DateMidnight();

endDate01.withYearOfEra(o1.getEndYearPeriod());
endDate01.withWeekOfWeekyear(o1.getEndWeekPeriod());

System.out.println(o1.getEndWeekPeriod() + " " + o1.getEndYearPeriod());
System.out.println(endDate01.getWeekOfWeekyear() + " " + endDate01.getYearOfEra());


我得到

37 2012

2012年16月16日

应该得到相同的结果,不是吗?

最佳答案

那些代码都可以正常工作

DateTime dt = new DateTime();
dt = dt.withWeekOfWeekyear(29);
dt = dt.withWeekyear(2011);

DateMidnight dt2 = new DateMidnight().withWeekOfWeekyear(29).withYear(2011);

10-05 22:24