Here you can find the source of getFileLastModified(File file)
Parameter | Description |
---|---|
file | a parameter |
public static String getFileLastModified(File file)
//package com.java2s; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**// w ww .java2s .c om * * @param file * @return the last modified date of the file with the default format : yyyy-MM-dd HH:mm:ss */ public static String getFileLastModified(File file) { return getFileLastModified(file, "yyyy-MM-dd HH:mm:ss"); } /** * * @param file * @param format * the date format like "yyyy-MM-dd" * @return the last modified date of the file */ public static String getFileLastModified(File file, String format) { Date date = new Date(file.lastModified()); SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date).toString(); } }