aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Miller-Cushon <cushon@google.com>2022-08-30 13:44:15 -0700
committerJavac Team <javac-team+copybara@google.com>2022-08-30 13:45:24 -0700
commitd42cb3322d5478148f395d269e2bf52cbfe01549 (patch)
tree76d039f8d7f1395c074920a5ec12f86e27d3309d
parentccd6bdc18d304be179089cbec1af0b128dcea1a5 (diff)
downloadturbine-d42cb3322d5478148f395d269e2bf52cbfe01549.tar.gz
Use `JarEntry#setTimeLocal`
This method was added in JDK 9, and allows setting jar entry times without going through a `long` of milliseconds. Both `setTime` and `setTimeLocal` implicitly use the default timezone. PiperOrigin-RevId: 471079483
-rw-r--r--java/com/google/turbine/main/Main.java10
1 files changed, 2 insertions, 8 deletions
diff --git a/java/com/google/turbine/main/Main.java b/java/com/google/turbine/main/Main.java
index da97bcd..34984a8 100644
--- a/java/com/google/turbine/main/Main.java
+++ b/java/com/google/turbine/main/Main.java
@@ -58,7 +58,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
-import java.time.ZoneId;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
@@ -433,16 +432,11 @@ public final class Main {
}
/** Normalize timestamps. */
- static final long DEFAULT_TIMESTAMP =
- LocalDateTime.of(2010, 1, 1, 0, 0, 0)
- .atZone(ZoneId.systemDefault())
- .toInstant()
- .toEpochMilli();
+ static final LocalDateTime DEFAULT_TIMESTAMP = LocalDateTime.of(2010, 1, 1, 0, 0, 0);
private static void addEntry(JarOutputStream jos, String name, byte[] bytes) throws IOException {
JarEntry je = new JarEntry(name);
- // TODO(cushon): switch to setLocalTime after we migrate to JDK 9
- je.setTime(DEFAULT_TIMESTAMP);
+ je.setTimeLocal(DEFAULT_TIMESTAMP);
je.setMethod(ZipEntry.STORED);
je.setSize(bytes.length);
je.setCrc(Hashing.crc32().hashBytes(bytes).padToLong());