Get date for a URL connection in Java
Description
The following code shows how to get date for a URL connection.
Example
// w ww.j a va 2 s . co m
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
URL u = new URL("http://www.google.com");
URLConnection uc = u.openConnection();
System.out.println("Date: " + new Date(uc.getDate()));
}
}
The code above generates the following result.