Use java.nio package for extracting the creation date and time of any file through java. To extract the date and time of the file use BasicFileAttributes class. java.nio package helps us to get the creation time, last access time, and last modified time, it works for both file and directory.
Import the necessary java libraries.
Store the path of the file whose creation time we want.
Create the path object and specify the path of the file into it.
Then we have to create BasicFileAttributes class using the readAttributes() method.
In readAttributes() method we have to pass two parameters which are path object and BasicFileAttributes class.
Now we have to just call creationTime() method using attributes.
Below is the implementation to get the creation time of the file:
// Java program to get the creation time of a file
Please Login to comment...