public static void main(String[] args) throws IOException { String path = "D:/Bin";//选择文件 File f =new File(path);//赋值为文件 Date d= new Date(f.lastModified());//定义时间函数,获取文件(path)的最后修改时间 SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义输出格式 System.out.println(sdf.format(d));//输出.按格式 }
原文:https://www.cnblogs.com/Gu1015/p/14304747.html