- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check the Date and time of Access (last modified) of a File using Java?
You can get the last modified date of a file using the lastModified() method of the File class.
Example
import java.io.File; import java.util.Date; public class FindingDirectories { public static void main(String args[]) { String dir ="C:/movies"; File directory = new File(dir); File[] fileList = directory.listFiles(); for (File file : fileList) { System.out.println(file.getName()); Date date = new Date(file.lastModified()); System.out.println(date.toString()); } } }
Output
Arundhati HD.mp4 Fri Dec 01 17:16:22 IST 2017 Okka Ammai Tappa.mkv Fri Nov 17 14:29:35 IST 2017 Padamati Sandhya Ragam.mp4 Wed Dec 06 09:53:07 IST 2017
- Related Articles
- How to check file last access time using Python?
- How to get file last modified time in Java?
- How to display the date and time of a document when it is last modified in JavaScript?
- C# Program to get the last access time of a file
- How to show the date and time the document was last modified with JavaScript?
- How to find the file modified after a certain date using PowerShell?
- How to get creation and modification date/time of a file using Python?
- How to set creation and modification date/time of a file using Python?
- How to check the Existence of a File using Java?
- How do you get the last access (and/or write) time of a MySQL database?
- C# Program to get the last write time of a file
- How to use Boto3 library in Python to get a list of files from S3 based on the last modified date using AWS Resource?
- Get the date/time of the last change to a MySQL database?
- How to check the permissions of a file using Python?
- How to check the Existence of a File using C#?

Advertisements