I am trying to create a date (07/29/2012 at 02:55:08 AM) in the time zone of Casablanca and received this exception:
Exception in thread "main" java.lang.IllegalArgumentException: HOUR_OF_DAY: 2 → 3 on java.util.GregorianCalendar.computeTime (Unknown source)
Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("Africa/Casablanca"));
cal.setLenient(false);
cal.set(Calendar.DATE, 29);
cal.set(Calendar.MONTH, 6);
cal.set(Calendar.YEAR, 2014);
cal.set(Calendar.HOUR_OF_DAY, 2);
cal.set(Calendar.MINUTE, 55);
cal.set(Calendar.SECOND, 8);
cal.getTime();
An exception is thrown with jre 1.7.0_71 and 1.8.0_20, but not with 1.6.0_30.
As far as I know, daylight saving time does not occur at this particular time. Any idea?
Thank!
source
share