Java IO Tutorial - Java unit)

Syntax unit) has the following syntax.

public long to(TimeUnit unit)


In the following code shows how to use unit) method.

/*from   w w w .  ja  v  a  2  s.  co m*/
import java.nio.file.attribute.FileTime;
import java.util.concurrent.TimeUnit;

public class Main {

  public static void main(String[] args) throws Exception {

    long time = System.currentTimeMillis();
    FileTime fileTime = FileTime.fromMillis(time);


The code above generates the following result.