原文地址:http://yangguangfu.iteye.com/blog/729760
- /**
- * 读取文件的最后修改时间的方法
- */
- private static String getFileLastModifiedTime(String filePath) {
- String path = filePath.toString();
- File f = new File(path);
- Calendar cal = Calendar.getInstance();
- long time = f.lastModified();
- SimpleDateFormat formatter = new
- SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- cal.setTimeInMillis(time);
- // 输出:修改时间[2] 2009-08-17 10:32:38
- return formatter.format(cal.getTime());
- }