Jump to content
  • 0

Schedule Event At X Day And N Hour


Afou To Patisa

Question

I'm trying to make an event to be scheduled using a configuration. Example the Configuration looks like this:

ScheduleConfiguration = 1,10:30 ; 3,15:30 ;

basically 1 means the 1st day of week (monday) and it will start at 10:30. The next event will start in 3rd day of week at 15:30. I did split the String but i stuck on how to schedule the event to happen every X days. Any help? Thank you

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

If you use aCis, you got ScheduledQuest which does exactly what you need.

 

If you don't use aCis, you have to code it yourself (using Calendar or the "new" Java8 API Time), either fully or using Quartz Scheduler for example.

Edited by Tryskell
Link to comment
Share on other sites

  • 0

If you use aCis, you got ScheduledQuest which does exactly what you need.

 

If you don't use aCis, you have to code it yourself (using Calendar or the "new" Java8 API Time), either fully or using Quartz Scheduler for example.

This is my code: 

for (final String timeOfDay : Config.RESTART_INTERVAL_BY_TIME_OF_DAY)
			{
				testStartTime = Calendar.getInstance();
				testStartTime.setLenient(true);
				
				String[] parts = timeOfDay.split(",");
				
				final int day = Integer.parseInt(parts[0]);
				final int hour = Integer.parseInt(parts[1].split(":")[0]);
				final int minute = Integer.parseInt(parts[1].split(":")[1]);
				
				testStartTime.set(Calendar.DAY_OF_WEEK, day);
				testStartTime.set(Calendar.HOUR_OF_DAY, hour);
				testStartTime.set(Calendar.MINUTE, minute);
				testStartTime.set(Calendar.SECOND, 00);

				timeUntilRestart = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();

i added as test  7,20:40  so this mean the next event must be on Sunday 20:40 but it schedule it for 18/6/2017  this is 2 days ago.. 

Link to comment
Share on other sites

  • 0

(Sunday = day 1)

 

As calendar reads for the current week you have to add days.

 

aloilf.png

 

 

I hope I helped

oh damn it sunday is 1st day for java calendar? :/ so i guess i have to add +1 day 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...