diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index 7eacaf239..9caede3fc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -824,9 +824,11 @@ public class Zip extends MatchingTask { if (! skipWriting) { ZipEntry ze = new ZipEntry (vPath); if (dir != null && dir.exists()) { - ze.setTime(dir.lastModified()); + // ZIPs store time with a granularity of 2 seconds, round up + ze.setTime(dir.lastModified() + 1999); } else { - ze.setTime(System.currentTimeMillis()); + // ZIPs store time with a granularity of 2 seconds, round up + ze.setTime(System.currentTimeMillis() + 1999); } ze.setSize (0); ze.setMethod (ZipEntry.STORED); @@ -957,7 +959,8 @@ public class Zip extends MatchingTask { FileInputStream fIn = new FileInputStream(file); try { - zipFile(fIn, zOut, vPath, file.lastModified(), null, mode); + // ZIPs store time with a granularity of 2 seconds, round up + zipFile(fIn, zOut, vPath, file.lastModified() + 1999, null, mode); } finally { fIn.close(); } diff --git a/src/main/org/apache/tools/zip/ZipOutputStream.java b/src/main/org/apache/tools/zip/ZipOutputStream.java index 71d4c0c89..bbc22ed63 100644 --- a/src/main/org/apache/tools/zip/ZipOutputStream.java +++ b/src/main/org/apache/tools/zip/ZipOutputStream.java @@ -653,7 +653,7 @@ public class ZipOutputStream extends DeflaterOutputStream { | (time.getDate() << 16) | (time.getHours() << 11) | (time.getMinutes() << 5) - | ((time.getSeconds() + 2) >> 1); + | (time.getSeconds() >> 1); byte[] result = new byte[4]; result[0] = (byte) ((value & 0xFF));