Getting and Setting the Modification Time of a File or Directory
import java.io.File;
publicclass Main {
publicstaticvoid main(String[] argv) throws Exception {
File file = newFile("filename");
long modifiedTime = file.lastModified();
// 0L is returned if the file does not exist
long newModifiedTime = System.currentTimeMillis();
boolean success = file.setLastModified(newModifiedTime);
if (!success) {
// operation failed.
}
}
}