Click here to watch in Youtube :
https://www.youtube.com/watch?v=ObeCawn_tJY&list=UUhwKlOVR041tngjerWxVccw
FileDemo.java
Outputhttps://www.youtube.com/watch?v=ObeCawn_tJY&list=UUhwKlOVR041tngjerWxVccw
FileDemo.java
import java.io.File; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; public class FileDemo { public static void main(String[] args) throws IOException, ParseException { File file = new File("D:/work/myfile.txt"); long lastModified = file.lastModified(); System.out.println("Before Format : " + lastModified); SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss"); String formatedStr = simpleDateFormat.format(lastModified); System.out.println("After Format,old lastModified : " + formatedStr); /* * Sets the last-modified time of the file or * directory named by this abstract pathname. */ file.setLastModified(System.currentTimeMillis()); lastModified = file.lastModified(); formatedStr = simpleDateFormat.format(lastModified); System.out.println("After Format,new lastModified : " + formatedStr); } }
Before Format : 1477195340491 After Format,old lastModified : 10/23/2016 09:32:20 After Format,new lastModified : 10/23/2016 09:34:20
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_File_change_lastModified_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_File_change_lastModified_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/a3d05269db9922e504bb1f9de8d07031990c9910/BasicJava/JavaIODemo_File_change_lastModified_App/?at=master
See also:
No comments:
Post a Comment