public class SchedulingUtils
extends java.lang.Object
getDelayTillMinute(int)
to
calculate the initial delay needed when scheduling with
SubmitterScheduler.scheduleAtFixedRate(Runnable, long, long)
, and then provide 1 hour
in milliseconds for the "period".Constructor and Description |
---|
SchedulingUtils() |
Modifier and Type | Method and Description |
---|---|
static long |
getDelayTillHour(int hour,
int minute)
Call to calculate how many milliseconds until the provided time.
|
static long |
getDelayTillMinute(int minute)
Call to calculate how many milliseconds until the provided minute.
|
static int |
shiftLocalHourToUTC(int hour)
This will shift an hour from the local time zone to UTC.
|
public static long getDelayTillMinute(int minute)
Because of use of Clock.lastKnownTimeMillis()
, this calculation will only be accurate
within about 100 milliseconds. Of course if provided to a scheduler, depending on it's work
load that variation may be greater.
minute
- Minute to calculate too, can not be negative and must be less than 60public static long getDelayTillHour(int hour, int minute)
It is important to note that the time zone for this hour is UTC. If you want to use this for
local time, just pass the hour through shiftLocalHourToUTC(int)
. This will convert
a local time's hour to UTC so that it can be used in this invocation.
Because of use of Clock.lastKnownTimeMillis()
, this calculation will only be accurate
within about 100 milliseconds. Of course if provided to a scheduler, depending on it's work
load that variation may be greater.
hour
- Hour in the 24 hour format, can not be negative and must be less than 24minute
- Minute to calculate too, can not be negative and must be less than 60public static int shiftLocalHourToUTC(int hour)
getDelayTillHour(int, int)
can be used with a local time zone hour.hour
- Hour to be shifted in the local time zone in 24 hour format