Merge branch '1.2.x'

pull/2141/merge
Andy Wilkinson 10 years ago
commit 02859cc2d4

@ -19,6 +19,7 @@ package org.springframework.boot.loader.jar;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.util.GregorianCalendar;
import java.util.zip.ZipEntry;
import org.springframework.boot.loader.data.RandomAccessData;
@ -145,7 +146,20 @@ public final class JarEntryData {
}
public long getTime() {
return Bytes.littleEndianValue(this.header, 12, 4);
long time = Bytes.littleEndianValue(this.header, 12, 2);
int seconds = (int) ((time << 1) & 0x3E);
int minutes = (int) ((time >> 5) & 0x3F);
int hours = (int) ((time >> 11) & 0x1F);
long date = Bytes.littleEndianValue(this.header, 14, 2);
int day = (int) (date & 0x1F);
int month = (int) ((date >> 5) & 0xF) - 1;
int year = (int) ((date >> 9) & 0x7F) + 1980;
return new GregorianCalendar(year, month, day, hours, minutes, seconds)
.getTimeInMillis();
}
public long getCrc() {

@ -170,6 +170,14 @@ public class JarFileTests {
assertThat(this.jarFile.size(), equalTo((int) this.rootJarFile.length()));
}
@Test
public void getEntryTime() throws Exception {
java.util.jar.JarFile jdkJarFile = new java.util.jar.JarFile(this.rootJarFile);
assertThat(this.jarFile.getEntry("META-INF/MANIFEST.MF").getTime(),
equalTo(jdkJarFile.getEntry("META-INF/MANIFEST.MF").getTime()));
jdkJarFile.close();
}
@Test
public void close() throws Exception {
RandomAccessDataFile randomAccessDataFile = spy(new RandomAccessDataFile(

Loading…
Cancel
Save