Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:14:17+00:00 2026-05-26T15:14:17+00:00

I have three code. This is the first one in which I get the

  • 0

I have three code. This is the first one in which I get the metadata information of any url and in that metadata I have LastModified date also. If I run this class then I get last modified date of url as–

key:- Last-Modified
value:- 2011-10-21T03:18:28Z

First one

public class App {

    private static Map<String, String> metaData;    

public static void main(String[] args) {

        Tika t = new Tika();

        Metadata md = new Metadata();
        URL u = null;
        try {
            u = new URL("http://www.xyz.com/documents/files/xyz-china.pdf");

            String content1= t.parseToString(u);
            System.out.println("hello" +content1);
        } catch (MalformedURLException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (TikaException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            Reader r = t.parse(u.openStream(), md);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
        for (String name : md.names()){
            String value = md.get(name);
            System.out.println("key:- " +name);
            System.out.println("value:- " +value);
            //getMetaData().put(name.toLowerCase(), md.get(name));
        }
        }
        catch(Exception e) {
            e.printStackTrace();
        }

    }

}

But for second example just below this when I run this code and with the same url. I get different Last Modified date of that URL. How to make sure which one is right. As I tried opening that pdf in the browser but instead of getting open in the browser. it is getting open with Adobe PDF on the computer not on the browser so I am not able to check through firebug.

Second Way–

public class LastMod{
  public static void main(String args[]) throws Exception {
    URL url = new URL("http://www.xyz.com/documents/files/xyz-china.pdf");

    System.out.println("URL:- " +url);
    URLConnection connection = url.openConnection();


    System.out.println(connection.getHeaderField("Last-Modified"));
    }
}

For the above one I get Las Mod date as-

Thu, 03 Nov 2011 16:59:41 +0000

Third Way–

public class Main{
  public static void main(String args[]) throws Exception {
    URL url = new URL("http://www.xyz.com/documents/files/xyz-china.pdf");
    HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();

    long date = httpCon.getLastModified();
    if (date == 0)
      System.out.println("No last-modified information.");
    else
      System.out.println("Last-Modified: " + new Date(date));

 }
}

And by third method I get it like this–

Last-Modified: Thu Nov 03 09:59:41 PDT 2011

I am confuse which one is right. I think first one is right. Any suggestions will be appreciated..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:14:18+00:00Added an answer on May 26, 2026 at 3:14 pm

    The first piece of code extracts the date from the metadata of the PDF file, while the two other ones get the information from the HTTP headers returned by the Web server. The first one is probably more accurate if you want to know when the document was created/modified.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this legacy code that I am working with and there is code
I have this code so far which perfectly but relies on there being a
I have trouble finding way to correctly refactor this code so that there would
I have code which needs to do something like this There is a list
I have a class, which returns three properties. First property is dependent on some
I have a barchart code snippet as below..When you run this,you get 4 bars
Hi this a part of my code : I have a list which its
I have a piece of code that looks like this: downloadsByExtensionCount = defaultdict(int) downloadsByExtensionList
Is there a better way to do this jquery code? Currently I have to
There is probably is simple fix for this but I currently have code similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.