I've solved this problem using JDK 7 with this code:
package FileCreationDate;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public class Main
{
public static void main(String[] args) {
File file = new File("c:\\1.txt");
Path filePath = file.toPath();
BasicFileAttributes attributes = null;
try
{
attributes =
Files.readAttributes(filePath, BasicFileAttributes.class);
}
catch (IOException exception)
{
System.out.println("Exception handled when trying to get file " +
"attributes: " + exception.getMessage());
}
long milliseconds = attributes.creationTime().to(TimeUnit.MILLISECONDS);
if((milliseconds > Long.MIN_VALUE) && (milliseconds < Long.MAX_VALUE))
{
Date creationDate =
new Date(attributes.creationTime().to(TimeUnit.MILLISECONDS));
System.out.println("File " + filePath.toString() + " created " +
creationDate.getDate() + "/" +
(creationDate.getMonth() + 1) + "/" +
(creationDate.getYear() + 1900));
}
}
}