Matthew Lancaster
Matthew Lancaster

Reputation: 519

Java - Packaging files (zip) changes lastModified date

Currently I have a mechanism that checks documents in and out of a system. If something has not been modified it will not check it in to the document management system. Unfortunately I've been zipping and unzipping files during this process now and any file that was unzipped/zipped has a new modified date instead of the actual modified date of the object.

Is there anyway in Java to determine the actual last time a file was opened and modified compared to being packaged?

Thanks!

Upvotes: 2

Views: 1909

Answers (1)

Moritz Petersen
Moritz Petersen

Reputation: 13057

Like this:

// when zipping:
ZipEntry e = ...
e.setTime(file.lastModified());

...

// when unzipping
File file = ...
file.setLastModified(e.getTime());

Upvotes: 5

Related Questions