To get file's last modification date we can use the lastModified() method of the File class. This method returns a long value. After getting this value you can create an instance of java.util.Dateclass and pass this value as the parameter. This Date will hold the file's last modification date.
import java.io.File;
import java.util.Date;
public class FileLastModificationDate
{
public static void main(String[] args)
{
// Create an instance of file object.
File file = new File("FileLastModificationDate.java");
// Get the last modification information.
Long lastModified = file.lastModified();
// Create a new date object and pass last modified information
// to the date object.
Date date = new Date(lastModified);
// We know when the last time the file was modified.
System.out.println(date);
}
}
Monday, March 5, 2012
How do I get file's last modification date in android?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment