Is there something special in the date 3rd of April 1942? For some reason the the hour of day 0 (12:00 am) is illegal for this specific date. The date is accepted when a lenient calendar is used but the hour of day is incremented to 1 (1:00 am).
Relevant code
java.util.Calendar calendar = java.util.Calendar.getInstance(
java.util.TimeZone.getTimeZone("Europe/Helsinki")
);
calendar.clear();
calendar.setLenient(false);
calendar.set(1942, 3, 3, 0, 0, 0);
calendar.getTimeInMillis();
Exception
java.lang.IllegalArgumentException: HOUR_OF_DAY
at java.util.GregorianCalendar.computeTime(Unknown Source)
at java.util.Calendar.updateTime(Unknown Source)
at java.util.Calendar.getTimeInMillis(Unknown Source)
I'd really prefer is the dates were not lenient as I don't want to accept impossible dates.
-- edit
As the accepted answer and many of the comments pointed out, this does indeed relate to daylight saving. On the 3rd of April 1942 at 00:00 daylight saving was tested in EEST/Helsinki timezone. Currently, daylight savings has been in use since 1981 and the clock is wound forward at 03:00 instead of 00:00. This means that e..g 28th of March 2010 03:00 does no exists in java.util.Calendar.
I'll just have to create a special case for this specific date in my code.
Just a guess, but is it related to daylight savings? I guess that would depend on the localization of your codebase (for the exact dates of daylight savings coming into effect) as well as other factors.
---EDIT--- Maybe not, since that was a Friday.
Timezones and daylight savings varied year by year, and 1942 is a particularly odd one in much of the world - various parts of were changing hands rather rapidly. Some parts of Asia were standardised to 'Burma Time' so transitioned from local times.
Your profile says you're in Finland, which was not so complicated. This world-time database puts the date and time in question as being within one hour lost to normal daylight saving.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With