I wonder if Calendar.roll respects its javadoc contract:
Running the following snippet
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("CST"));
cal.setTimeInMillis(1457928024812l);
System.out.println(cal.getTime());
cal.roll(Calendar.HOUR_OF_DAY, true);
System.out.println(cal.getTime());
yiels the following output:
Sun Mar 13 23:00:24 CDT 2016
Sun Mar 13 23:00:24 CDT 2016
The 13 of March 2016 was a Daylight Saving change at 2 am (from CST to CDT). The javadoc of roll states that roll "adds a single unit of time", and here no units of time is added. Is it the expected behavior of this method?
EDIT:
I reported this as a bug. For more information, here is the link to the corresponding OpenJDK ticket: https://bugs.openjdk.java.net/browse/JDK-8152077