File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
src/main/java/org/codehaus/plexus/archiver Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 22
22
import java .lang .reflect .UndeclaredThrowableException ;
23
23
import java .nio .charset .Charset ;
24
24
import java .util .ArrayList ;
25
- import java .util .Calendar ;
26
25
import java .util .Comparator ;
27
26
import java .util .Date ;
28
27
import java .util .HashMap ;
Original file line number Diff line number Diff line change @@ -838,10 +838,21 @@ protected String getArchiveType()
838
838
@ Override
839
839
protected Date convertSourceDateEpochToDate ( int sourceDateEpoch )
840
840
{
841
- // timestamp of zip entries at zip storage level ignores timezone: see https://github.com/Stuk/jszip/issues/369
842
- Calendar cal = Calendar . getInstance ();
843
- long zipTime = 1000L * sourceDateEpoch - ( cal . get ( Calendar . ZONE_OFFSET ) + cal . get ( Calendar . DST_OFFSET ) );
844
- return new Date ( zipTime );
841
+ // timestamp of zip entries at zip storage level ignores timezone: managed in ZipEntry.setTime,
842
+ // that turns javaToDosTime: need to revert the operation here to get reproducible
843
+ // zip entry time
844
+ return new Date ( dosToJavaTime ( 1000L * sourceDateEpoch ) );
845
845
}
846
846
847
+ /**
848
+ * Converts DOS time to Java time (number of milliseconds since epoch).
849
+ *
850
+ * @see java.util.zip.ZipEntry#setTime
851
+ * @see java.util.zip.ZipUtils#dosToJavaTime
852
+ */
853
+ private static long dosToJavaTime ( long dtime )
854
+ {
855
+ Calendar cal = Calendar .getInstance ();
856
+ return dtime - ( cal .get ( Calendar .ZONE_OFFSET ) + cal .get ( Calendar .DST_OFFSET ) );
857
+ }
847
858
}
You can’t perform that action at this time.
0 commit comments