Java 文件修改日期lastModified2


Java 文件修改日期lastModified2

import java.io.File;
import java.text.SimpleDateFormat;

public class GetFileLastModifiedExample {
   public static void main(String[] args) {
      File file = new File("Main.java");
      System.out.println("Before Format : " + file.lastModified());
      SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      System.out.println("After Format : " + sdf.format(file.lastModified()));
   }
}