First lastModified returns:
A long value representing the time the file was last modified,
measured in milliseconds since the epoch (00:00:00 GMT, January 1,
1970), or 0L if the file does not exist or if an I/O error occurs
You need to get current time in milliseconds then subtract what last modified returns and the verify if it was modified before your target period. Or perform the time calculation in any type you desire.
Following your code:
long day = 1000 * 60 * 60 * 24;
long now = System.currentTimeMillis();
for(File file: new File(DIRECTORY).listFiles())
if (!file.isDirectory() && (now - file.lastModified() > day))
file.delete();
Ideally you would be running this as an scheduled task