Java FileTime.to(TimeUnit unit)

Syntax

FileTime.to(TimeUnit unit) has the following syntax.

public long to(TimeUnit unit)

Example

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


/*from   w  w w.  j av  a 2  s.  c o  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);
    System.out.println(fileTime.to(TimeUnit.HOURS));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio.file.attribute »




BasicFileAttributes
BasicFileAttributeView
DosFileAttributes
FileTime
PosixFileAttributes
PosixFilePermissions