Convert File Last Modified Time stamp Date
In this sample program you will see how to convert file last modified time stamp to date format using java.
- ChangeLastModified.java
package com.javahonk; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; public class ChangeLastModified { public static void main(String[] args) { File file = new File("C:\\JavaHonk\\Log4jXML.log"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy HH-mm-ss"); String modifiedDate = simpleDateFormat.format(new Date(file.lastModified())); System.out.println("File last modifed date: " +modifiedDate); } }
- Output:
- For more information about file modification please refer oracle tutorial here