2

How can I know the date a webpage last-modified using Android Java? or how I can request for

If-Modified-Since: Allows a 304 Not Modified to be returned if content is unchanged

using http headers?

Hesham Saeed
  • 5,358
  • 7
  • 37
  • 57
  • No, I think last-modified is open for anyone, otherwise how google will sort things by date? – Hesham Saeed Jul 13 '12 at 00:05
  • I am not certain, but if they were to check every day and compare what is there to what they got last time they'd be able to tell roughly when the change occurred. – FoamyGuy Jul 13 '12 at 00:06
  • That can be done, but last-modified and if-modified-since are there in http request & response for some reason! – Hesham Saeed Jul 13 '12 at 00:09

1 Answers1

3

I could do it this way:

URL url = null;
        try {
            url = new URL("http://www.example.com/example.pdf");
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        HttpURLConnection httpCon = null;
        try {
            httpCon = (HttpURLConnection) url.openConnection();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        long date = httpCon.getLastModified();
Hesham Saeed
  • 5,358
  • 7
  • 37
  • 57