Get Last Modified Date of File in Java

Price: INR 1,299.00
Was: INR 1,799.00

Let’s see How can you get last modified date of File in Java. Sometimes we need to get the file last modified date in java usually, for listeners like JBoss config file changes hot deployment. To get the last modified date, you can use the File.lastModified() to get the file’s last modified timestamps. This method will return the time

This method will return the time in milliseconds (long value), you may format it with SimpleDateFormat to make it a human readable format.

 

Get Last Modified Date of File in Java with Example

Let’s understand this with an easy example. In the last tutorial, we have created a Text file named ‘TargetFile.txt’ . In this example, we will get the modified date of this file –

 

The above code will print the last modified date of TargetFile.txt. In my case, the output will be —

Before Format Date -1448467090509
After Format date — Wed Nov 25 21:28:10 IST 2015 

Using this way, You can get the last modified date of the file in Java.

0 Comment

Leave a Reply