Here you can find the source of setTimes(Path path, Date time)
public static void setTimes(Path path, Date time) throws IOException
//package com.java2s; /*!/*from w w w . j ava2 s. c o m*/ * mifmi-commons4j * https://github.com/mifmi/mifmi-commons4j * * Copyright (c) 2015 mifmi.org and other contributors * Released under the MIT license * https://opensource.org/licenses/MIT */ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.FileTime; import java.util.Date; public class Main { public static void setTimes(Path path, Date time) throws IOException { FileTime fileTime = FileTime.fromMillis(time.getTime()); BasicFileAttributeView attrs = Files.getFileAttributeView(path, BasicFileAttributeView.class); attrs.setTimes(fileTime, fileTime, fileTime); } public static void setTimes(Path path, long time) throws IOException { FileTime fileTime = FileTime.fromMillis(time); BasicFileAttributeView attrs = Files.getFileAttributeView(path, BasicFileAttributeView.class); attrs.setTimes(fileTime, fileTime, fileTime); } public static void setTimes(Path path, Date lastModifiedTime, Date lastAccessTime, Date creationTIme) throws IOException { BasicFileAttributeView attrs = Files.getFileAttributeView(path, BasicFileAttributeView.class); attrs.setTimes((lastModifiedTime == null) ? null : FileTime.fromMillis(lastModifiedTime.getTime()), (lastAccessTime == null) ? null : FileTime.fromMillis(lastAccessTime.getTime()), (creationTIme == null) ? null : FileTime.fromMillis(creationTIme.getTime())); } public static void setTimes(Path path, long lastModifiedTime, long lastAccessTime, long creationTIme) throws IOException { BasicFileAttributeView attrs = Files.getFileAttributeView(path, BasicFileAttributeView.class); attrs.setTimes(FileTime.fromMillis(lastModifiedTime), FileTime.fromMillis(lastAccessTime), FileTime.fromMillis(creationTIme)); } }