esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

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!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.