user1955923
user1955923

Reputation: 1

Comparing timestamp in hadoop hdfs

I'm very new to hadoop and all and i have a question on hand. Is there a way to do a comparison of the timestamp between two files in the HDFS?

Any help is much appreciated.

Upvotes: 0

Views: 907

Answers (1)

Chris White
Chris White

Reputation: 30089

Use the FileSystem.getFileStatus(Path) method to get a FileStatus object back, from which you can acquire the file's modified time via FileStaus.getModifiedTime() method

FileSystem fs = FileSystem.get(conf);
long ts1 = fs.getFileStatus(new Path("/path/to/file1")).getModifiedTime();
long ts2 = fs.getFileStatus(new Path("/path/to/file2")).getModifiedTime();

Upvotes: 2

Related Questions