|
@@ -3,9 +3,9 @@ package org.dbsyncer.listener.quartz.filter;
|
|
|
import org.dbsyncer.common.util.DateFormatUtil;
|
|
|
import org.dbsyncer.listener.quartz.QuartzFilter;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
+import java.sql.Date;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
|
|
|
public class YesDateFilter implements QuartzFilter {
|
|
|
|
|
@@ -17,19 +17,15 @@ public class YesDateFilter implements QuartzFilter {
|
|
|
|
|
|
@Override
|
|
|
public Object getObject() {
|
|
|
- Date as = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000);
|
|
|
- SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String time = matter1.format(as) + " 00:00:00";
|
|
|
+ LocalDateTime localDateTime;
|
|
|
if (!begin) {
|
|
|
- time = matter1.format(as) + " 23:59:59";
|
|
|
+ // 2022-08-02 23:59:59
|
|
|
+ localDateTime = LocalDateTime.now().withHour(23).withMinute(59).withSecond(59).withNano(999999999);
|
|
|
+ } else {
|
|
|
+ // 2022-08-02 00:00:00
|
|
|
+ localDateTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
}
|
|
|
- matter1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- try {
|
|
|
- as = matter1.parse(time);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return as;
|
|
|
+ return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -46,4 +42,5 @@ public class YesDateFilter implements QuartzFilter {
|
|
|
public boolean begin() {
|
|
|
return begin;
|
|
|
}
|
|
|
+
|
|
|
}
|