Simply use the lastModified() method from a file object. but the return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.

 String s1 = "file1.dat";
String s2 = "file2.dat";

File f1 = new File(s1);
File f2 = new File(s2);

if (f1.lastModified() < f2.lastModified())
   System.out.println(s1 + " is older than " + s2);