Is there anything special about April 3, 1942? For some reason, hour day 0 (12:00 AM) is illegal for this particular date. The date is accepted when the soft calendar is used, but the hour of the day increases to 1 (1:00 in the morning).
Corresponding 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();
An 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 would prefer the dates not to be lenient, since I don't want to accept impossible dates.
- edit
As the accepted answer and many of the comments noted, this is indeed related to summer savings. On April 3, 1942 at 00:00, daylight saving time was checked in the EEST / Helsinki time zone. Currently, summer savings have been used since 1981, and the clock is wound at 03:00 instead of 00:00. This means that e..g March 28, 2010 03:00 a.m. does not exist in java.util.Calendar.
I just need to create custom code for this particular date in my code.
source share