* added helper method

This commit is contained in:
Reinhard Pointner 2014-04-19 07:31:24 +00:00
parent 9a485bb5a2
commit 2199e67357
1 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,10 @@ package net.filebot.format;
import static java.util.regex.Pattern.*; import static java.util.regex.Pattern.*;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -286,4 +290,13 @@ public class ExpressionFormatMethods {
return 0; return 0;
} }
public static long getCreationDate(File self) throws IOException {
BasicFileAttributes attr = Files.getFileAttributeView(self.toPath(), BasicFileAttributeView.class).readAttributes();
long creationDate = attr.creationTime().toMillis();
if (creationDate > 0) {
return creationDate;
}
return attr.lastModifiedTime().toMillis();
}
} }