src/java.base/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -30,14 +30,15 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
import java.util.HashSet;
import java.util.Set;
import java.util.SortedMap;
-import java.util.TimeZone;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
import java.util.zip.CRC32;
@@ -93,17 +94,13 @@
}
if (out == null) {
throw new NullPointerException("null output");
}
assert(Utils.currentInstance.get() == null);
- TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
- ? null
- : TimeZone.getDefault();
try {
Utils.currentInstance.set(this);
- if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
BufferedInputStream in0 = new BufferedInputStream(in);
if (Utils.isJarMagic(Utils.readMagic(in0))) {
if (verbose > 0)
Utils.log.info("Copying unpacked JAR file...");
@@ -123,11 +120,10 @@
Utils.markJarFile(out);
}
} finally {
_nunp = null;
Utils.currentInstance.set(null);
- if (tz != null) TimeZone.setDefault(tz);
}
}
/**
* Takes an input File containing the pack file, and generates a JarOutputStream.
@@ -244,13 +240,13 @@
je.setMethod(JarEntry.STORED);
je.setSize(bufOut.size());
je.setCrc(crc.getValue());
}
if (keepModtime) {
- je.setTime(file.modtime);
- // Convert back to milliseconds
- je.setTime((long)file.modtime * 1000);
+ LocalDateTime ldt = LocalDateTime
+ .ofEpochSecond(file.modtime, 0, ZoneOffset.UTC);
+ je.setTimeLocal(ldt);
} else {
je.setTime((long)modtime * 1000);
}
out.putNextEntry(je);
bufOut.writeTo(out);