|
Java™ by example!
|
|
|
How do I check the last-modified date of a URL file?
The getLastModified() Method in the URLConnection connection class allows you to get the Last modified date. It can be done in the following manner:
... String urlpath = new String("http://www.esus.com/respondquestionexample.html"); url = new URL(urlpath); connection = url.openConnection(); connection.connect(); System.out.println(urlpath+ " was last modified on "+ new java.util.Date(connection.getLastModified())); ...
|
The getLastModified() method returns a long value, the number of seconds since the start of the epoch( 1970 ) till the modified date. The output for the above url was "Last Modified on Thu Apr 19 03:01:25 GMT+05:30 2001"
Further Information
Author of answer: Ranjith
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|