Skip to content
Advertisement

Using Timer.schedule to make java program run at a specific time Not working

I am trying to get use Timer.schedule() to make a task run automatically at a certain time. However, it is not working. my code:

  1. I tried to set up a timer task first
  2. I then tried to create a Date object using the current time
  3. I then use Timer.schedule(timertask, date) to tell the computer when to do the task. However, the timertask doesn’t start at the specified date. Please help, thank you.
JavaScript

Advertisement

Answer

When doing calendar.set(year, month, day, hour, minute, second) month needs to be one less than the current month. For example, May is 4. problem solved!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement