为什么 withWeekOfWeekyear 给我一个不同的偏移量?

Why is withWeekOfWeekyear giving me a different offset?

我正在尝试将 withWeekOfWeekyear 转换为 java.time。我似乎无法弄清楚为什么与 weekOfWeekBasedYear 相比,withWeekOfWeekyear 得到的偏移量不同。

    DateTime dateTimeWeek = new DateTime().withWeekOfWeekyear(1);
    OffsetDateTime offsetDateTimeWeek = OffsetDateTime.now().with(WeekFields.ISO.weekOfWeekBasedYear(), 1);

    DateTime dateTime = new DateTime();
    OffsetDateTime offsetDateTime = OffsetDateTime.now();

    System.out.println(dateTimeWeek); // 2016-01-04T12:20:50.981-05:00
    System.out.println(offsetDateTimeWeek); // 2016-01-04T12:20:51.034-04:00

    System.out.println(dateTime); // 2016-07-18T12:20:51.101-04:00
    System.out.println(offsetDateTime); // 2016-07-18T12:20:51.101-04:00

org.joda.time.DateTime 可识别时区。

A DateTime calculates its fields with respect to a time zone.

java.time.OffsetDateTime 时区感知,即不针对夏令时进行调整。

OffsetDateTime adds to the instant the offset from UTC/Greenwich, which allows the local date-time to be obtained. ZonedDateTime adds full time-zone rules.

java.time.ZonedDateTime 时区感知,所以如果你使用它,你应该得到相同的结果。

ZonedDateTime is an immutable representation of a date-time with a time-zone.