org.ijsberg.iglu.util.time
Class TimeSupport
java.lang.Object
org.ijsberg.iglu.util.time.TimeSupport
public abstract class TimeSupport
- extends Object
Contains convenience methods concerning time and date.
|
Method Summary |
static long |
determineMillisUntilNextInterval(int intervalInMinutes,
long gmtOffset)
|
static long |
floorToIntervalStart(int intervalInMinutes,
long time,
long gmtOffset)
Determines the exact time an interval starts based on a time within the interval. |
static int |
getIntervalsSinceMidnight(int intervalInMinutes,
long timeInMillis,
long gmtOffset)
|
static int |
getMinutesSinceMidnight(long gmtOffset)
|
static int |
getMinutesSinceMidnight(long timeInMillis,
long gmtOffset)
|
static boolean |
isAfterToday(Date date)
|
static boolean |
isBeforeToday(Date date)
|
static boolean |
isIntervalStart(int intervalInMinutes,
int offsetInMinutes,
long gmtOffset)
|
static boolean |
isIntervalStart(int intervalInMinutes,
long gmtOffset)
|
static boolean |
isSameDay(long time1,
long time2)
|
static boolean |
isSameInterval(int intervalInMinutes,
long time1,
long time2,
long gmtOffset)
|
static boolean |
isSameWeek(long time1,
long time2)
|
static boolean |
isToday(Date date)
|
static long |
roundToMinute(long time)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
defaultGMTOffsetInMillis
public static final long defaultGMTOffsetInMillis
TimeSupport
public TimeSupport()
isToday
public static boolean isToday(Date date)
- Parameters:
date -
- Returns:
- true if the given date happens to be today
isBeforeToday
public static boolean isBeforeToday(Date date)
- Parameters:
date -
- Returns:
- true if the given date is on a day earlier than today
isAfterToday
public static boolean isAfterToday(Date date)
- Parameters:
date -
- Returns:
- true if the given date is on a day later than today
getMinutesSinceMidnight
public static int getMinutesSinceMidnight(long gmtOffset)
- Returns:
- The number of minutes passed since 00:00 hours
getMinutesSinceMidnight
public static int getMinutesSinceMidnight(long timeInMillis,
long gmtOffset)
- Parameters:
timeInMillis -
- Returns:
- The number of minutes passed since 00:00 hours
getIntervalsSinceMidnight
public static int getIntervalsSinceMidnight(int intervalInMinutes,
long timeInMillis,
long gmtOffset)
- Parameters:
intervalInMinutes - intervalInMinutes in minutestimeInMillis -
- Returns:
- the number of passed intervals since midnight
isSameInterval
public static boolean isSameInterval(int intervalInMinutes,
long time1,
long time2,
long gmtOffset)
- Parameters:
intervalInMinutes - intervalInMinutes in minutestime1 - time in millistime2 - time in millis
- Returns:
- true if the two specified times are part of the same intervalInMinutes
isSameDay
public static boolean isSameDay(long time1,
long time2)
- Parameters:
time1 - time in millistime2 - time in millis
- Returns:
- true if the two specified times are part of the same day
isSameWeek
public static boolean isSameWeek(long time1,
long time2)
- Parameters:
time1 - time in millistime2 - time in millis
- Returns:
- true if the two specified times are part of the same week
floorToIntervalStart
public static long floorToIntervalStart(int intervalInMinutes,
long time,
long gmtOffset)
- Determines the exact time an interval starts based on a time within the interval.
- Parameters:
intervalInMinutes - time - time in millis
- Returns:
- the exact time in milliseconds the interval begins
roundToMinute
public static long roundToMinute(long time)
- Parameters:
time - time in millis
- Returns:
- time in milles rounded to the minute
isIntervalStart
public static boolean isIntervalStart(int intervalInMinutes,
int offsetInMinutes,
long gmtOffset)
- Parameters:
intervalInMinutes - offsetInMinutes -
- Returns:
- true if an interval starts this minute
isIntervalStart
public static boolean isIntervalStart(int intervalInMinutes,
long gmtOffset)
- Parameters:
intervalInMinutes -
- Returns:
- true if a (page) interval starts this minute
determineMillisUntilNextInterval
public static long determineMillisUntilNextInterval(int intervalInMinutes,
long gmtOffset)
- Parameters:
intervalInMinutes -
- Returns:
- the number of milliseconds to wait until the next interval starts
Copyright © 2011. All Rights Reserved.