In Joda-Time version 2.9.9 I want to remove time part of
Only for time zone
Asia/Tehran and some dates like (2036-03-21, 2037-03-21, ...) it returns
1:00:00 in time part of result.
I also checked the Joda-Time source code but I couldn't find any problem.
The code is:
DateTime dt = new DateTime(2036, 03, 21, 10, 0, DateTimeZone.forID(Asia/Tehran)); dt = dt.withTimeAtStartOfday();
Time is not zero. This only happens for zone
My system config:
I solved this problem by converting
LocalDate, but I want to know why this problem happens?
This is because Iran switches from Standard time to Daylight Savings time at 00:00 on the 21st or 22nd of March (whichever day contains the astronomical equinox). In 2036 this happens on the 21st. In 2018 it happens to fall on the 22nd.
In short, the time jumps from
2036/03/20 24:00 to
2036/03/21 01:00. The hour from midnight to 1 AM does not exist on that specific day.
When writing code that deals with time, ALWAYS keep in mind that unexpected small offsets from expected results are almost surely due to administrative time changes. This is even more true for historical dates, where offsets could be any number of minutes and seconds, not just whole or half-hours.