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?
I hope your myDir contains the path of directory
Following snippet works for me
The long variable returned by object dir needs to be converted like below, using your example.
For date setting, try function setLastModified( long Time ).
For reference, a Java link @ Java 1.7
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..