I want a Quartz timer service for the update code below. Every six months, all users' keys should be updated according to their creationDate
:
//dataTypes are date only
List<User> allDbUsers=userRepository.findAll();
Date currDate=new Date();
final long DAY_IN_MILLIS = 1000 * 60 * 60 * 24;
for(User user:allDbUsers)
{
Date creationDate=user.getCreationDate();
String firstKey=user.getFirstKey();
Long diffInDays=(currDate.getTime()-creationDate.getTime())/DAY_IN_MILLIS;
if(diffInDays==180)
{
user.setSecondKey(firstKey);
user.setFirstKey("aH&#KK");
userRepository.saveAndFlush(user);
}
}