I have an application that needs to play some specifics audios(mp3) periodically. Let me give one example: Every Monday at 8:00am -> hello.mp3. How can I do that in Java?? I´m trying using Calendar, JodaTime, but I cant do it.
Depends, if you are using JEE, you can use EJB Timer. And there is always Quartz http://www.quartz-scheduler.org/
What a Timer
can help you to achieve is so minimum, Quartz Scheduler is a well-known (and easy-to-use) scheduler that accepts cron-like expression.
If you use Spring in your application, it has a scheduling module that can keep your Quartz code even cleaner.
You should use java.util.Timer
to define schedules and java.util.TimerTask
to define job. You can also use well-known Quartz Scheduler.
If you use Spring, you can use its scheduling service (it can be configured to use either Quartz Scheduler or java.util.Timer
in its work).
If you run desktop App, the easiest way is to use java.util.Timer
. For more complicated schedules use Quartz Scheduler.