mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 10:05:58 +01:00
Migrate from date to instant
This commit is contained in:
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
|
||||
public class FileFilter {
|
||||
private final Set<String> excluded;
|
||||
private final Pattern includePattern;
|
||||
private final Date filterDate;
|
||||
private final Instant filterDate;
|
||||
private final LastExecutionHandler lastExecutionHandler;
|
||||
|
||||
private final String EXTENSION_GROUP = "extension";
|
||||
@@ -52,10 +52,6 @@ public class FileFilter {
|
||||
return includePattern.matcher(pathName.getName()).matches();
|
||||
}
|
||||
|
||||
private boolean isNewer(File pathName, Date date) {
|
||||
return isNewer(pathName, date.toInstant());
|
||||
}
|
||||
|
||||
private boolean isNewer(File pathName, Instant date) {
|
||||
if (date == null) return true;
|
||||
try {
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.apache.commons.lang3.SystemUtils;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -56,7 +57,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
|
||||
@Option(names = {"-n", "--only-new-files"}, description = "ignores all files unchanged and previously processed")
|
||||
private boolean onlyNewFiles;
|
||||
@Option(names = {"-d", "--filter-date"}, defaultValue = Option.NULL_VALUE, description = "only consider files created newer than entered date (format: \"dd.MM.yyyy-HH:mm:ss\")")
|
||||
private Date filterDate;
|
||||
private Instant filterDate;
|
||||
@Option(names = {"-i", "--include-pattern"}, defaultValue = ".*", description = "include files matching pattern")
|
||||
private Pattern includePattern;
|
||||
@Option(names = {"-e", "--exclude"}, arity = "1..*",
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package at.pcgamingfreaks.mkvaudiosubtitlechanger.util;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateUtils {
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy-HH:mm:ss");
|
||||
|
||||
public static Date convert(long millis) {
|
||||
return new Date(millis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert String to date.
|
||||
* @return parsed date, defaultDate if exception occurs
|
||||
*/
|
||||
public static Date convert(String date, Date defaultDate) {
|
||||
try {
|
||||
return dateFormat.parse(date);
|
||||
} catch (ParseException e) {
|
||||
return defaultDate;
|
||||
}
|
||||
}
|
||||
|
||||
public static String convert(Date date) {
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user