## Time Keeps Ticking

##### September 9, 2013
testing java

A note so that I never forget again: the time used by a ZipEntry instance in Java appears to keep ticking.

ZipEntry entry = new ZipEntry("foo");
long expected = System.currentTimeMillis();
entry.setTime(expected);
long seen = entry.getTime()

// This fails
assertEquals(expected, seen);


Update: it turns out that the problem turns out to be that DOS timestamps only store seconds with a precision of 2 seconds. The above could be reduced to:

ZipEntry entry = new ZipEntry("foo");

// Note: we set the seconds to an odd number
long expected = Calendar.getInstance()
.set(2013, SEPTEMBER, 10, 12, 14, 1)
.getTimeInMillis();
entry.setTime(expected);
long seen = entry.getTime()

// This fails
assertEquals(expected, seen);


More on MSDN.

More recently On the Naming of Tests     On Managing Time and Direct Emails About Selenium Less recently

tech java

selenium testing

tech testing