migrate from java.util.Date to java.time

This commit is contained in:
Athou
2024-01-08 20:42:45 +01:00
parent b1a4debb95
commit 69c9988404
35 changed files with 203 additions and 206 deletions

View File

@@ -1,10 +1,9 @@
package com.commafeed.backend.task;
import java.util.Date;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.time.DateUtils;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.service.DatabaseCleaningService;
@@ -23,7 +22,7 @@ public class OldEntriesCleanupTask extends ScheduledTask {
public void run() {
int maxAgeDays = config.getApplicationSettings().getMaxEntriesAgeDays();
if (maxAgeDays > 0) {
Date threshold = DateUtils.addDays(new Date(), -1 * maxAgeDays);
Instant threshold = Instant.now().minus(Duration.ofDays(maxAgeDays));
cleaner.cleanEntriesOlderThan(threshold);
}
}

View File

@@ -1,6 +1,6 @@
package com.commafeed.backend.task;
import java.util.Date;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import com.commafeed.CommaFeedConfiguration;
@@ -19,7 +19,7 @@ public class OldStatusesCleanupTask extends ScheduledTask {
@Override
public void run() {
Date threshold = config.getApplicationSettings().getUnreadThreshold();
Instant threshold = config.getApplicationSettings().getUnreadThreshold();
if (threshold != null) {
cleaner.cleanStatusesOlderThan(threshold);
}