Add yyyymmdd date pattern

@see https://www.filebot.net/forums/viewtopic.php?f=8&t=3409
This commit is contained in:
Reinhard Pointner 2016-02-10 02:48:28 +00:00
parent 856972e4da
commit 95ea4130ec
2 changed files with 5 additions and 3 deletions

View File

@ -16,7 +16,7 @@ public class DateMatcher {
private final DatePattern[] patterns;
public DateMatcher() {
patterns = new DatePattern[6];
patterns = new DatePattern[7];
// match yyyy-mm-dd patterns like 2010-10-24, 2009/6/1, etc
patterns[0] = new NumericDatePattern("(?<!\\p{Alnum})(\\d{4})[^\\p{Alnum}](\\d{1,2})[^\\p{Alnum}](\\d{1,2})(?!\\p{Alnum})", new int[] { 1, 2, 3 });
@ -35,6 +35,9 @@ public class DateMatcher {
// match dd.MMM.yyyy patterns like 8 Sep 2015
patterns[5] = new DateFormatPattern("(?<!\\p{Alnum})(\\d{1,2})[^\\p{Alnum}](?i:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[^\\p{Alnum}](\\d{4})(?!\\p{Alnum})", "dd MMM yyyy");
// match yyyymmdd patterns like 20140408
patterns[6] = new DateFormatPattern("(?<!\\p{Alnum})(\\d{8})(?!\\p{Alnum})", "yyyymmdd");
}
public DateMatcher(DatePattern... patterns) {

View File

@ -120,8 +120,7 @@ public class SimpleDate implements Serializable, Comparable<Object> {
date.setTime(formatter.parse(string));
return new SimpleDate(date.get(YEAR), date.get(MONTH) + 1, date.get(DAY_OF_MONTH)); // Calendar months start at 0
} catch (ParseException e) {
// no result if date is invalid
// Logger.getLogger(Date.class.getName()).log(Level.WARNING, e.getMessage());
// date is invalid
return null;
}
}