org.ijsberg.iglu.util.time
Class SchedulingSupport

java.lang.Object
  extended by org.ijsberg.iglu.util.time.TimeSupport
      extended by org.ijsberg.iglu.util.time.SchedulingSupport

public class SchedulingSupport
extends TimeSupport


Field Summary
 
Fields inherited from class org.ijsberg.iglu.util.time.TimeSupport
DAY_IN_MINS, DAY_IN_MS, HALF_MINUTE_IN_MS, HOUR_IN_MS, LOCAL_UTC_OFFSET, LOCAL_UTC_OFFSET_IN_MINUTES, MINUTE_IN_MS, SECOND_IN_MS
 
Constructor Summary
SchedulingSupport()
           
 
Method Summary
static long calculateOffsetInMs(int intervalInMinutes, int offsetInMinutes)
          Reformulates negative offsets or offsets larger than interval.
static int getIntervalsSinceMidnight(long time, int intervalInMinutes)
           
static long getNextIntervalStart(long time, int intervalInMinutes)
          Determines the exact time the next interval starts based on a time within the current interval.
static long getNextIntervalStart(long time, int intervalInMinutes, int offsetInMinutes)
          Determines the exact time the next interval starts based on a time within the current interval.
static long getPreviousIntervalStart(long time, int intervalInMinutes)
          Determines the exact time an interval starts based on a time within the interval.
static long getPreviousIntervalStart(long time, int intervalInMinutes, int offsetInMinutes)
          Determines the exact time an interval starts based on a time within the interval.
static long getTimeTillIntervalStart(long time, int intervalInMinutes)
           
static long getTimeTillIntervalStart(long time, int intervalInMinutes, int offsetInMinutes)
           
static boolean isIntervalRegularDaily(int intervalInMinutes)
           
static boolean isWithinMinuteOfIntervalStart(long time, int intervalInMinutes)
           
static boolean isWithinMinuteOfIntervalStart(long time, int intervalInMinutes, int offsetInMinutes)
          Useful for scheduling jobs checking every minute on the minute if an event should be triggered.
static boolean isWithinSameInterval(long time1, long time2, int intervalInMinutes)
           
static boolean isWithinSameInterval(long time1, long time2, int intervalInMinutes, int offsetInMinutes)
           
 
Methods inherited from class org.ijsberg.iglu.util.time.TimeSupport
getMinutesSinceMidnight, getMinutesSinceMidnight, getUtcOffset, isAfterToday, isBeforeToday, isSameDay, isSameWeek, isToday, roundToMinute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchedulingSupport

public SchedulingSupport()
Method Detail

getIntervalsSinceMidnight

public static int getIntervalsSinceMidnight(long time,
                                            int intervalInMinutes)
Parameters:
time -
intervalInMinutes - should be > 0
Returns:
the number of passed intervals since midnight in local time zone

getPreviousIntervalStart

public static long getPreviousIntervalStart(long time,
                                            int intervalInMinutes)
Determines the exact time an interval starts based on a time within the interval.

Parameters:
time - time in millis
intervalInMinutes -
Returns:
the exact time in milliseconds the interval begins local time

isIntervalRegularDaily

public static boolean isIntervalRegularDaily(int intervalInMinutes)
Parameters:
intervalInMinutes -
Returns:

calculateOffsetInMs

public static long calculateOffsetInMs(int intervalInMinutes,
                                       int offsetInMinutes)
Reformulates negative offsets or offsets larger than interval.

Parameters:
intervalInMinutes -
offsetInMinutes -
Returns:
offset in milliseconds

getPreviousIntervalStart

public static long getPreviousIntervalStart(long time,
                                            int intervalInMinutes,
                                            int offsetInMinutes)
Determines the exact time an interval starts based on a time within the interval.

Parameters:
time - time in millis
intervalInMinutes -
offsetInMinutes -
Returns:
the exact time in milliseconds the interval begins local time

getNextIntervalStart

public static long getNextIntervalStart(long time,
                                        int intervalInMinutes)
Determines the exact time the next interval starts based on a time within the current interval.

Parameters:
time - time in millis
intervalInMinutes -
Returns:
the exact time in milliseconds the interval begins local time

getNextIntervalStart

public static long getNextIntervalStart(long time,
                                        int intervalInMinutes,
                                        int offsetInMinutes)
Determines the exact time the next interval starts based on a time within the current interval.

Parameters:
time - time in millis
intervalInMinutes -
offsetInMinutes -
Returns:
the exact time in milliseconds the interval begins local time

isWithinSameInterval

public static boolean isWithinSameInterval(long time1,
                                           long time2,
                                           int intervalInMinutes)
Parameters:
time1 - time in millis
time2 - time in millis
intervalInMinutes - should be > 0
Returns:
true if the two specified times are part of the same intervalInMinutes in local time zone

isWithinSameInterval

public static boolean isWithinSameInterval(long time1,
                                           long time2,
                                           int intervalInMinutes,
                                           int offsetInMinutes)
Parameters:
time1 - time in millis
time2 - time in millis
intervalInMinutes - should be > 0
Returns:
true if the two specified times are part of the same intervalInMinutes in local time zone

isWithinMinuteOfIntervalStart

public static boolean isWithinMinuteOfIntervalStart(long time,
                                                    int intervalInMinutes)
Parameters:
intervalInMinutes -
Returns:
true if a (page) interval starts this minute in local time zone

isWithinMinuteOfIntervalStart

public static boolean isWithinMinuteOfIntervalStart(long time,
                                                    int intervalInMinutes,
                                                    int offsetInMinutes)
Useful for scheduling jobs checking every minute on the minute if an event should be triggered.

Parameters:
time -
intervalInMinutes -
offsetInMinutes -
Returns:
true if an interval starts this minute local time

getTimeTillIntervalStart

public static long getTimeTillIntervalStart(long time,
                                            int intervalInMinutes)
Parameters:
intervalInMinutes -
Returns:
the number of milliseconds to wait until the next interval starts in local time zone

getTimeTillIntervalStart

public static long getTimeTillIntervalStart(long time,
                                            int intervalInMinutes,
                                            int offsetInMinutes)
Parameters:
intervalInMinutes -
Returns:
the number of milliseconds to wait until the next interval starts in local time zone


Copyright © 2012. All Rights Reserved.