com.atlassian.scheduler.core.util
Class TimeIntervalQuantizer
java.lang.Object
com.atlassian.scheduler.core.util.TimeIntervalQuantizer
public class TimeIntervalQuantizer
- extends Object
Tool for quantizing millisecond time intervals to a broader resolution while
guarding against sign overflows.
- Since:
- v1.0
|
Method Summary |
static long |
quantize(long intervalInMilliseconds,
int resolution)
Quantizes millisecond time intervals to the specified resolution, rounding up. |
static long |
quantizeToMinutes(long intervalInMilliseconds)
Quantizes millisecond time intervals to a one minute resolution, rounding up. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimeIntervalQuantizer
public TimeIntervalQuantizer()
quantize
public static long quantize(long intervalInMilliseconds,
int resolution)
- Quantizes millisecond time intervals to the specified resolution, rounding up.
Examples:
quantize(0,50) → 0
quantize(123,10) → 130
quantize(11,15000) → 15000
quantize(127249,60000) → 180000
- Parameters:
intervalInMilliseconds - the time interval to be quantizedresolution - the time resolution to honour, in milliseconds.
- Returns:
- the quantized time interval, in milliseconds with the specified resolution
quantizeToMinutes
public static long quantizeToMinutes(long intervalInMilliseconds)
- Quantizes millisecond time intervals to a one minute resolution, rounding up.
Examples:
quantizeToMinutes(0) → 0
quantizeToMinutes(123) → 60000
quantizeToMinutes(127249) → 180000
- Parameters:
intervalInMilliseconds - the time interval to be quantized
- Returns:
- the quantized time interval, in milliseconds with one minute resolution
Copyright © 2014 Atlassian. All Rights Reserved.