What you are looking for is a planner. Quartz is probably the most used scheduler in the Java world, although Spring has some interesting scheduling features if you already use this framework.
Whichever scheduler you choose, you usually indicate the action (sometimes called the "task") and the time it occurred (the "trigger" in quartz terminology). In your case, you have to start the trigger every day at midnight, and when it is fired, it will do everything you need in accordance with your work.
Garyf
source share