diff options
author | cushon <cushon@google.com> | 2018-02-12 12:46:03 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-12 12:48:26 -0800 |
commit | 0526bd10d4309b71488f1bf9e9449b19c134b662 (patch) | |
tree | c878ddd27ded9fa92085f9102e11d1bd75e890b2 /src/java_tools/buildjar | |
parent | 7ae2b77aaea54bec036370186ef653eab21310aa (diff) |
Use a different date time when normalizing zip entries
PiperOrigin-RevId: 185419668
Diffstat (limited to 'src/java_tools/buildjar')
-rw-r--r-- | src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/ZipUtil.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/ZipUtil.java b/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/ZipUtil.java index a4e7d7e033..a9f764aad9 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/ZipUtil.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/ZipUtil.java @@ -15,7 +15,8 @@ package com.google.devtools.build.java.turbine.javac; import java.io.IOException; -import java.util.GregorianCalendar; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.zip.CRC32; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -25,9 +26,12 @@ import java.util.zip.ZipOutputStream; */ public abstract class ZipUtil { - /** The earliest date representable in a zip file, the DOS epoch. */ - private static final long DOS_EPOCH = - new GregorianCalendar(1980, 0, 1, 0, 0, 0).getTimeInMillis(); + /** Normalize timestamps. */ + static final long DEFAULT_TIMESTAMP = + LocalDateTime.of(2010, 1, 1, 0, 0, 0) + .atZone(ZoneId.systemDefault()) + .toInstant() + .toEpochMilli(); /** * This is a helper method for adding an uncompressed entry to a @@ -41,7 +45,8 @@ public abstract class ZipUtil { throws IOException { ZipEntry entry = new ZipEntry(name); entry.setMethod(ZipEntry.STORED); - entry.setTime(DOS_EPOCH); + // TODO(cushon): switch to setLocalTime after we migrate to JDK 9 + entry.setTime(DEFAULT_TIMESTAMP); entry.setSize(content.length); CRC32 crc32 = new CRC32(); crc32.update(content); |