Example usage for java.nio.file.attribute FileTime to

List of usage examples for java.nio.file.attribute FileTime to

Introduction

In this page you can find the example usage for java.nio.file.attribute FileTime to.

Prototype

public long to(TimeUnit unit) 

Source Link

Document

Returns the value at the given unit of granularity.

Usage

From source file:Main.java

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

    long time = System.currentTimeMillis();
    FileTime fileTime = FileTime.fromMillis(time);
    System.out.println(fileTime.to(TimeUnit.HOURS));

}

From source file:com.att.aro.core.fileio.impl.FileManagerImpl.java

public long getCreatedTime(String filePath) throws IOException {
    File file = new File(filePath);
    FileTime fileTime = (FileTime) Files.getAttribute(file.toPath(), "creationTime", LinkOption.NOFOLLOW_LINKS);
    if (fileTime != null) {
        return fileTime.to(TimeUnit.SECONDS);
    }//w w  w. j a va 2  s  . c  o  m
    return 0;
}