I’m looking for a way to get a directories modification date. I’ve tried:
File dir = new File(myDir);
long mod = dir.lastModified();
But it’s returning 0.
I’m also looking for a way to set the last modification date of a directory but haven’t found anything.
Is there a documented way to do these?
Edit:
Your code looks right, Just check the existence of directory..
Returns the time when this file was last modified, measured in milliseconds since January 1st, 1970, midnight. Returns 0 if the file does not exist.
So just check whether your file is exist or not..
CODE:
For get Last modified date from file,
To set Last Modified date to a file..