Polish
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -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.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
@@ -31,6 +32,7 @@ import org.springframework.boot.loader.util.AsciiBytes;
|
||||
* the entry is actually needed.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public final class JarEntryData {
|
||||
|
||||
@@ -146,20 +148,27 @@ public final class JarEntryData {
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
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);
|
||||
long time = Bytes.littleEndianValue(this.header, 12, 2);
|
||||
return decodeMsDosFormatDateTime(date, time).getTimeInMillis();
|
||||
}
|
||||
|
||||
int day = (int) (date & 0x1F);
|
||||
int month = (int) ((date >> 5) & 0xF) - 1;
|
||||
/**
|
||||
* Decode MSDOS Date Time details. See <a
|
||||
* href="http://mindprod.com/jgloss/zip.html">mindprod.com/jgloss/zip.html</a> for
|
||||
* more details of the format.
|
||||
* @param date the date part
|
||||
* @param time the time part
|
||||
* @return a {@link Calendar} containing the decoded date.
|
||||
*/
|
||||
private Calendar decodeMsDosFormatDateTime(long date, long time) {
|
||||
int year = (int) ((date >> 9) & 0x7F) + 1980;
|
||||
|
||||
return new GregorianCalendar(year, month, day, hours, minutes, seconds)
|
||||
.getTimeInMillis();
|
||||
int month = (int) ((date >> 5) & 0xF) - 1;
|
||||
int day = (int) (date & 0x1F);
|
||||
int hours = (int) ((time >> 11) & 0x1F);
|
||||
int minutes = (int) ((time >> 5) & 0x3F);
|
||||
int seconds = (int) ((time << 1) & 0x3E);
|
||||
return new GregorianCalendar(year, month, day, hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public long getCrc() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user