After 9 months of inactivity I chose to update my software including updating from jdk7u17 to u51. Some of my tests started to fail. Here is one:
public void testSimpleDateFormatDefaultTimeZone() throws ParseException {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long millis = sf.parse("1927-12-31 23:54:08").getTime()
- sf.parse("1927-12-31 23:54:07").getTime();
assertEquals(millis, 353000L);
sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
millis = sf.parse("1927-12-31 23:54:08").getTime()
- sf.parse("1927-12-31 23:54:07").getTime();
assertEquals(millis, 353000L);
sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
millis = sf.parse("1927-12-31 23:54:08").getTime()
- sf.parse("1927-12-31 23:54:07").getTime();
assertEquals(millis, 1000L);
}
It passes on u17 and fails at the first assertEquals starting with u25. u21 is ok. From u25 onwards, millis is calculated to be 1000.