java.nio.file.attribute.FileTime Class in Java Last Updated : 28 Mar, 2022 Comments Improve Suggest changes Like Article Like Report The java.nio.file.attribute.FileTime class is used to get a value representing this file's timestamp i.e, the time when this file was last modified, accessed, or created. Class Declaration: public final class FileTime extends Object implements Comparable<FileTime>Methods: MethodDescriptioncompareTo(FileTime other)This method compares the value of two FileTime objects for the order.equals(Object obj)This method tests this FileTime for equality with the given object.from(Instant instant)This method returns a FileTime representing the same point of time value on the time-line as the provided Instant object.from(long value, TimeUnit unit)This method returns a FileTime representing a value at the given unit of granularity.fromMillis(long value)This method returns a FileTime representing the given value in milliseconds.hashCode()This method computes a hash code for this file time.to(TimeUnit unit)This method returns the value at the given unit of granularity.toInstant()This method converts this FileTime object to an Instant.toMillis()This method returns the value in milliseconds.toString()This method returns the string representation of this FileTime.Below is the implementation of some methods from java.nio.file.attribute.FileTime class in java: Java import java.nio.file.attribute.FileTime; import java.time.Instant; import java.util.concurrent.TimeUnit; public class GFG { public static void main(String[] args) { // Variables for storing time values long v1 = 21; long v2 = 356; // Creating an Instant. Instant instant = Instant.parse("2017-02-03T10:37:30.00Z"); // Creating FileTime object using from // Method This method takes an Integer // value and a timeunit as parameters. FileTime filetime2 = FileTime.from(v2, TimeUnit.MILLISECONDS); // Creating FileTime object using fromMillis method. FileTime filetime1 = FileTime.fromMillis(v1); // Creating FileTime object using from Method // This method takes an Instant as parameters. FileTime filetime3 = FileTime.from(instant); // Method to convert this filetime to an instant. Instant instantFromFileTime = filetime3.toInstant(); // Method to convert filetime1 to this timeunit. System.out.println( filetime1.to(TimeUnit.MILLISECONDS)); // Method to check if filetime1 // is equal to filetime2 or not. if (filetime1.equals(filetime2)) System.out.println("FileTime are equal"); else System.out.println("FileTime are not equal"); // Method to print hashvalue of filetime1. System.out.println(filetime1.hashCode()); // Method to convert filetime1 to milliseconds. System.out.println(filetime1.toMillis()); // Method to compare filetime1 and filetime2. System.out.println(filetime1.compareTo(filetime2)); // Method to print string // representation of filetime1. System.out.println(filetime1.toString()); } } Output21 FileTime are not equal 1071000000 21 -1 1970-01-01T00:00:00.021Z Comment More infoAdvertise with us Next Article java.nio.file.attribute.FileTime Class in Java A abhinavjain194 Follow Improve Article Tags : Java Java-NIO package Practice Tags : Java Similar Reads java.nio.file.FileStore Class in Java Java.nio.file is a package in java that consists of the FileStore class. FileStore class is a class that provides methods for the purpose of performing some operations on file store. FileStore is a class that extends Object from java.lang package. And few methods the FileStore class can inherit from 4 min read java.nio.file.FileSystem class in java java.nio.file.FileSystem class provides an interface to a file system. The file system acts as a factory for creating different objects like Path, PathMatcher, UserPrincipalLookupService, and WatchService. This object help to access the files and other objects in the file system. Syntax: Class decla 4 min read java.nio.file.attribute.AclEntry Class in Java ACL entries are Examined by this class is validating on the ACL model declared in RFC 3530: Network File System i.e.(NFS) version of 4th Protocol and having four components within it as follows characteristics as follows: This type of component are determining if the entry grants or denies its acce 3 min read java.nio.file.spi.FileTypeDetector Class in Java java.nio.file.spi.FileTypeDetector Class extends java.lang.Object Class. FileTypeDetector Class contain method to know about the content type of given file. Class declaration: public abstract class FileTypeDetector extends ObjectConstructor: ConstructorDescriptionprotected FileTypeDetector()It is us 2 min read java.nio.file.Paths Class in Java java.nio.file.Paths class contains static methods for converting path string or URI into Path. Class declaration : public final class Paths extends ObjectMethods: MethodDescriptionget(String first, String... more) This method converts a path string, or a sequence of strings that when joined form a p 2 min read java.nio.file.LinkPermission Class in Java The java.nio.file.LinkPermission class handles permissions for link creation operations. The permission allowed by these class are as follows: Permission name What permission allows Risk of granting this permission hard This permission allows adding an existing file to a directory. This operation is 3 min read java.time.Instant Class in Java In Java language, the Instant Class is used to represent the specific time instant on the current timeline. The Instant Class extends the Object Class and implements the Comparable interface. Declaration of the Instant Class public final class Instant extends Object implements Temporal, TemporalAdju 4 min read File Attributes in OS Storing data is an essential component of using computers. We all store data in files. Whatever the type of files may be, we use files daily. While using files you also may have come across the 'file attributes'. They are nothing but the characteristics of the file itself. File Attributes is an esse 5 min read java.nio.file.SimpleFileVisitor Class in Java The java.nio.file.SimpleFileVisitor Class is used to visit all the files in a directory and to re-throw I/O exceptions whenever an I/O error occurs. Class declaration : public class SimpleFileVisitor<T> extends Object implements FileVisitor<T>Constructor: protected SimpleFileVIsitor(): C 3 min read java.time.Duration Class in Java Duration is the value-based Class present in the Java time library. It's used to get time-based amount of time. This class is immutable and thread-safe. This article describes all the methods present in this class and some basic examples using class methods. This class implements Serializable, Comp 4 min read Like