Get the date of a url connection : HttpURLConnection « Network Protocol « Java

Get the date of a url connection


import java.util.Date;

public class Main{
  public static void main(String args[]) throws Exception {
    URL url = new URL("");
    HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();

    long date = httpCon.getDate();
    if (date == 0)
      System.out.println("No date information.");
      System.out.println("Date: " + new Date(date));



Related examples in the same category

1.Get the document expiration date
2.Get the document Last-modified date
3.Show the content type
4.Show the content length
5.Display request method
6.Get response code
7.Display response message
8.Display header information
9.Download and display the content
10.A Web Page Source Viewer
11.Reading from a URLConnection
12.Use BufferedReader to read content from a URL
13.Check if a page exists
14.Identify ourself to a proxy
15.Connect through a Proxy
16.Preventing Automatic Redirects in a HTTP Connection
17.Converting x-www-form-urlencoded Data
18.Getting the Cookies from an HTTP Connection
19.Sending a Cookie to an HTTP Server
20.Getting the Response Headers from an HTTP Connection can be used to send the credentials when needed
22.Grabbing a page using socket
23.Http Header Helper
24.Http connection Utilities
25.Available Port Finder