Dave Ranjan
Dave Ranjan

Reputation: 2984

Need content-created date of a file in Java

I know there are several questions asked around this, but no Java solution. My question is same:

My goal is to display the date of an Excel file. But if I download the file from the internet, automatically the creation date and modify date are set to current time and date. I looked upon the file's properties, and found that in section 'Details' , under personal information , there is a section called 'Source' and there , it has a property called 'Content Created' with the original date file.

So, I don't want :- Not this

but this :-

enter image description here

Upvotes: 2

Views: 742

Answers (1)

RaffleBuffle
RaffleBuffle

Reputation: 5455

POI does support the xls format, though the method for extracting the properties is different from xlsx.

HSSFWorkbook wb = (HSSFWorkbook)WorkbookFactory.create(new File("sample.xls"));             
SummaryInformation props = wb.getSummaryInformation();
System.out.println("Content Created: " + props.getCreateDateTime());

Output:

Content Created: Tue Nov 22 07:49:38 PST 2005

Here's a screenshot of the sample.xls properties that confirms that the required date is being extracted.

enter image description here

Upvotes: 5

Related Questions