Implementations[edit]
File file = new File("filename");
// Get the last modified time
long modifiedTime = file.lastModified();
// 0L is returned if the file does not exist
// Set the last modified time
long newModifiedTime = System.currentTimeMillis();
boolean success = file.setLastModified(newModifiedTime);
if (!success) {
// operation failed.
}
fname = "file_name"
# Get the last access time and the last modified time
puts atime = File.atime(fname) # last access time
puts mtime = File.mtime(fname) # modification time
# Set the last modified time
mtime = Time.now
File.utime(atime, mtime, fname)