java2db

Get or Set Last Modified Date and Time for a File or directory in java



The java class File having the methods to Get or Set Last Modified Date for a file. To do so, create a File (class) object with the file path and call the below methods.

 
Get or Set Last Modified Date lastModified()  :  This method returns Last Modified Date as a long value(milliseconds).
Get or Set Last Modified Date setLastModified(long)  : This method takes a long argument and returns true if the specified date

and time modified successfully, otherwise it returns false.

 

Syntax:

long <name>= <FileObjectName>.lastModified();
Boolean <name>=<FileObjectName>.setLastModified(long );

Example Code to Get and Set Last Modified Date:

Execution Result:

Get or Set Last Modified Date In the same way we can  set or get the last modified date and time for a directory.

 




Related Posts :
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java SOAP web service in php ( php web service client )
Solution to SSLHandshakeException (skip the certificate for Java and LDAP bind)
Java RESTful web service example in maven using JAX-RS
RESTful web service example in java using JAX-RS
   [will not be published]



^ <