Date Of URL Connection In Java Example
Chapter:
Networking
Last Updated:
29-04-2016 18:34:52 UTC
Program:
/* ............... START ............... */
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
public class JavaDateOfURLConnection {
public static void main(String args[]) throws Exception {
URL url = new URL("http://www.google.com");
HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
long date = httpConnection.getDate();
if (date == 0)
System.out.println("No date information.");
else
System.out.println("Date: " + new Date(date));
}
}
/* ............... END ............... */
Output
Date: Fri Apr 29 22:27:33 GST 2016
Tags
Date Of URL Connection, Java, Networking