public static void main(String[] args) {
System.out.println("Norfolk Island times as per Joda Time");
IntStream.range(1, 13)
.forEach(month -> System.out.println(DateTime.now((DateTimeZone.forID("Pacific/Norfolk")))
.withYear(2023)
.withMonthOfYear(month)
.withDayOfMonth(10)
.withHourOfDay(2)
.withMinuteOfHour(10)
.withSecondOfMinute(2)
.withMillisOfSecond(0)));
System.out.println("-------------------------------------");
System.out.println("Norfolk Island times as per JDK OffsetDateTime");
IntStream.range(1, 13)
.forEach(month -> System.out.println(OffsetDateTime.now(ZoneId.of("Pacific/Norfolk"))
.withYear(2023)
.withMonth(month)
.withDayOfMonth(10)
.withHour(2)
.withMinute(10)
.withSecond(2)
.withNano(0)));
System.out.println("-------------------------------------");
}
Output:
Norfolk Island times as per Joda Time
2023-01-10T02:10:02.000+12:00
2023-02-10T02:10:02.000+12:00
2023-03-10T02:10:02.000+12:00
2023-04-10T02:10:02.000+11:00
2023-05-10T02:10:02.000+11:00
2023-06-10T02:10:02.000+11:00
2023-07-10T02:10:02.000+11:00
2023-08-10T02:10:02.000+11:00
2023-09-10T02:10:02.000+11:00
2023-10-10T02:10:02.000+12:00
2023-11-10T02:10:02.000+12:00
2023-12-10T02:10:02.000+12:00
-------------------------------------
Norfolk Island times as per JDK OffsetDateTime
2023-01-10T02:10:02+11:00
2023-02-10T02:10:02+11:00
2023-03-10T02:10:02+11:00
2023-04-10T02:10:02+11:00
2023-05-10T02:10:02+11:00
2023-06-10T02:10:02+11:00
2023-07-10T02:10:02+11:00
2023-08-10T02:10:02+11:00
2023-09-10T02:10:02+11:00
2023-10-10T02:10:02+11:00
2023-11-10T02:10:02+11:00
2023-12-10T02:10:02+11:00
-------------------------------------
So as per JodaTime, they observe DST, but OffsetDateTime says they do not.
Which one is correct? Or I am doing somthing wrong?
Java: JDK 1.8.0.311
JodaTime: 2.10.10