com.jidesoft.utils
Class TimeUtils
java.lang.Object
com.jidesoft.utils.TimeUtils
public class TimeUtils
- extends Object
Method Summary |
static Date |
createTime(String timeString)
Makes it easier to create Date objects from strings without having to remember the symbols required for a
SimpleDateFormat. |
static double |
daysDiff(Calendar c1,
Calendar c2)
|
static double |
hoursDiff(Calendar c1,
Calendar c2)
|
static boolean |
isSameDay(Calendar c1,
Calendar c2)
|
static boolean |
isSameHour(Calendar c1,
Calendar c2)
|
static boolean |
isSameInField(int field,
Calendar c1,
Calendar c2)
|
static boolean |
isSameMillis(Calendar c1,
Calendar c2)
|
static boolean |
isSameMinute(Calendar c1,
Calendar c2)
|
static boolean |
isSameMonth(Calendar c1,
Calendar c2)
|
static boolean |
isSameSecond(Calendar c1,
Calendar c2)
|
static boolean |
isSameWeek(Calendar c1,
Calendar c2)
|
static boolean |
isSameYear(Calendar c1,
Calendar c2)
|
static Calendar |
max(Calendar c1,
Calendar c2)
|
static long |
millisDiff(Calendar c1,
Calendar c2)
|
static Calendar |
min(Calendar c1,
Calendar c2)
|
static double |
minutesDiff(Calendar c1,
Calendar c2)
|
static Integer |
mostSignificantDifference(Calendar c1,
Calendar c2)
|
static double |
secondsDiff(Calendar c1,
Calendar c2)
|
static double |
weeksDiff(Calendar c1,
Calendar c2)
|
static double |
yearsDiff(Calendar c1,
Calendar c2)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimeUtils
public TimeUtils()
createTime
public static Date createTime(String timeString)
throws ParseException
- Makes it easier to create Date objects from strings without having to remember the symbols required for a
SimpleDateFormat.
The format used is "dd-MMM-yyyy HH:mm:ss", so an acceptable date is for example 05-Dec-1999
20:04:15
- Parameters:
timeString
- a time string in the format "dd-MMM-yyyy HH:mm:ss" (eg. 05-Dec-1999 20:04:15)
- Returns:
- a
Date
object corresponding to the date/time in the supplied string.
- Throws:
ParseException
mostSignificantDifference
public static Integer mostSignificantDifference(Calendar c1,
Calendar c2)
- Parameters:
c1
- c2
-
- Returns:
- the int field from the Calendar class at which the dates differ. This will be one of YEAR, MONTH,
WEEK_OF_YEAR, DAY_OF_YEAR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND, or null if there are no
differences.
isSameYear
public static boolean isSameYear(Calendar c1,
Calendar c2)
isSameMonth
public static boolean isSameMonth(Calendar c1,
Calendar c2)
isSameWeek
public static boolean isSameWeek(Calendar c1,
Calendar c2)
isSameDay
public static boolean isSameDay(Calendar c1,
Calendar c2)
isSameHour
public static boolean isSameHour(Calendar c1,
Calendar c2)
isSameMinute
public static boolean isSameMinute(Calendar c1,
Calendar c2)
isSameSecond
public static boolean isSameSecond(Calendar c1,
Calendar c2)
isSameMillis
public static boolean isSameMillis(Calendar c1,
Calendar c2)
isSameInField
public static boolean isSameInField(int field,
Calendar c1,
Calendar c2)
yearsDiff
public static double yearsDiff(Calendar c1,
Calendar c2)
weeksDiff
public static double weeksDiff(Calendar c1,
Calendar c2)
daysDiff
public static double daysDiff(Calendar c1,
Calendar c2)
hoursDiff
public static double hoursDiff(Calendar c1,
Calendar c2)
minutesDiff
public static double minutesDiff(Calendar c1,
Calendar c2)
secondsDiff
public static double secondsDiff(Calendar c1,
Calendar c2)
millisDiff
public static long millisDiff(Calendar c1,
Calendar c2)
min
public static Calendar min(Calendar c1,
Calendar c2)
max
public static Calendar max(Calendar c1,
Calendar c2)