1

I had copied a file to my android device. When i check it's last modified date with file.lastModified() it returns the date the file was created which is just now. I want the original date when the file was last modified and not copied. I can see this date in windows explorer with the tag Date modified .The file.lastModified() matches with the Date created Tag of the file. If i could get the last Modified Date i can update the file with another file from server after it has been updated by just checking the date. But with created date it is not possible.

nissim_dev
  • 323
  • 2
  • 14
  • I'm not familiar with the quirks of Android; do you get a different result from java.nio.file.Files.getLastModifiedTime()? – Jason C Aug 07 '13 at 04:10
  • Is it java.io? the file i am referring here is a file on my sdcard created using File file = new File(Environment.getExternalStorageDirectory(),"test.xml") i cannot use the method you mentioned – nissim_dev Aug 07 '13 at 04:57
  • A bit confused - is your program that calls file.lastModified() running on the Andrioid device? Also is it checking the lastModified() of the file on the device? When you say Windows Explorer shows the Date modified for the file correctly, then are we talking about the file lying on the server? – Prahalad Deshpande Aug 07 '13 at 05:16
  • yes it is running on android device and it is checking the lastModified() of the file on device. windows explorer shows date modified correctly for the file in the device not in the server. but when i use the file.lastmodified() method it returns the date created not the last modified date i can see in windows which is the original modified date – nissim_dev Aug 07 '13 at 05:36
  • @user2049132 No, nio is what I meant, but java.nio.file.* is not in Java 6, only 7. – Jason C Aug 07 '13 at 06:21

1 Answers1

2

I got Creation date of a document using apache tika in java

Here is my java code to get creation date of document:

public class tikaExample {

    public static void main(String[] args) throws SAXException, TikaException {
        InputStream is = null;

        try {
            is = new BufferedInputStream(new FileInputStream(new File("/home/rahul/Downloads/darknet5.doc")));

            Parser parser = new AutoDetectParser();
            BodyContentHandler handler = new BodyContentHandler();

            Metadata metadata = new Metadata();

            parser.parse(is, handler, metadata, new ParseContext());
            System.out.println("creation date "+metadata.get(Metadata.CREATION_DATE));
            System.out.println("last modify date "+metadata.get(Metadata.LAST_MODIFIED));           
        } catch (IOException e) {
            e.printStackTrace();
        }

and output of this code is :

 creation date 2002-10-16T05:45:00Z
 last modify date 2013-07-01T05:12:00Z

that is creation date and time of file.

Rahul Kulhari
  • 1,115
  • 1
  • 15
  • 44