Here you can find the source of daysOld(File file)
Parameter | Description |
---|---|
file | The file to get the age of |
public static int daysOld(File file)
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.Calendar; public class Main { /**//from w w w .j a va2 s . c om * Returns the number of days since a file has been modified * * @param file The file to get the age of */ public static int daysOld(File file) { if (file.lastModified() < 1) return 0; return milliToDay(Calendar.getInstance().getTimeInMillis() - file.lastModified()); } /** * Converts milliseconds to days */ public static int milliToDay(long milli) { return (int) ((double) milli / (1000 * 24 * 60 * 60)); } }