package ch.rasc.eds.starter.schedule;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;

import ch.rasc.eds.starter.config.MongoDb;
import ch.rasc.eds.starter.entity.CUser;
import ch.rasc.eds.starter.entity.User;

@Component
public class DisableInactiveUser {

	private final MongoDb mongoDb;

	@Autowired
	public DisableInactiveUser(MongoDb mongoDb) {
		this.mongoDb = mongoDb;
	}

	@Scheduled(cron = "0 0 5 * * *")
	public void doCleanup() {
		// Inactivate users that have a lastAccess timestamp that is older than one year
		ZonedDateTime oneYearAgo = ZonedDateTime.now(ZoneOffset.UTC).minusYears(1);
		this.mongoDb.getCollection(User.class).updateMany(
				Filters.lte(CUser.lastAccess, oneYearAgo),
				Updates.set(CUser.enabled, false));
	}

}

@@ -92,16 +92,39 @@
 ateTime;
+%0Aimport java.util.Date;
 %0A%0Aimport
@@ -976,26 +976,49 @@
 Access, 
-oneYearAgo
+Date.from(oneYearAgo.toInstant())
 ),%0A%09%09%09%09U

Fix query. Has to use java.util.Date