Java 设置文件修改日期lastModified


Java 设置文件修改日期lastModified

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

public class GetFileLastModifiedExample {
   public static void main(String[] args) {
      File f1 = new File("C:\\\\Users\\\\codingdict7\\\\Desktop\\\\abc.png");
      System.out.println("Before Format : " + f1.lastModified());
      SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      System.out.println("After Format : " + sdf.format(f1.lastModified()));
   }
}