After 9 months of inactivity, I decided to update my software, including upgrading from jdk7u17 to u51. Some of my tests began to fail. Here is one of them:
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 switches to u17 and fails on the first assertEquals, starting with u25. u21 is fine. Starting with u25, millis is calculated as 1000.
source
share