DateTime gives an unexpected result

I tried this with Jodatime DateTime ,

  DateTime dateTime = DateTime .parse("1-JAN-1900", DateTimeFormat.forPattern("dd-MMM-yyyy")) .plusSeconds(2075866000); String dateTimeStr = DateTimeFormat.forPattern( "yyyy/MM/dd HH:mm:ss").print(dateTime); System.out.println(dateTimeStr); 

I also tried using Jodatime MutableDateTime

  MutableDateTime dateTime = MutableDateTime .parse("1-JAN-1900", DateTimeFormat.forPattern("dd-MMM-yyyy")); dateTime.add(DurationFieldType.seconds(), 2075866000); String dateTimeStr = DateTimeFormat.forPattern( "yyyy/MM/dd HH:mm:ss").print(dateTime.toDateTime()); System.out.println(dateTimeStr); 

Both give me the same result, 1965/10/13 06:09:54 .

I expect 1965/10/13 05:26:40 , instead. I get this using the Oracle query below

 select to_date('1900-JAN-1') + 2075866000/86400 from dual 

And after the conflict between Joda and Oracle, I tried Wolframalpha , which also gives me the same result as Oracle.

Can someone please explain why this difference?

+6
source share
1 answer

According to timeanddate.com in Kuala Lumpur in 1901, 1905, 1933, 1941, 1942, 1945 there were time zone adjustments, the total of which probably explains the discrepancy that you see.

Edit: In fact, if you add up all the settings you get 43:14, this is exactly the discrepancy you see.

JodaTime and Java give you the correct numbers.

+4
source

Source: https://habr.com/ru/post/916814/


All Articles