public class DateUtility
extends java.lang.Object
Constructor and Description |
---|
DateUtility() |
Modifier and Type | Method and Description |
---|---|
static java.util.Date |
addDays(java.util.Date date,
int plusDays)
Add a number of days to a date.
|
static java.util.Date |
addHours(java.util.Date date,
double hours)
Add a number of hours to a date.
|
static java.util.Date |
addMinutes(java.util.Date date,
int plusMinutes)
Add a number of minutes to a date.
|
static java.util.Date |
addSeconds(java.util.Date date,
int plusSeconds)
Add a number of seconds to a date.
|
static boolean |
after(java.util.Date clickdate,
java.util.Date start)
Returns true if clickdate is after start date.
|
static boolean |
afterOrEquals(java.util.Date clickdate,
java.util.Date start)
Returns true if clickdate is equals or after start date.
|
static boolean |
before(java.util.Date clickdate,
java.util.Date end)
Returns true if the clickdate is before the end date.
|
static boolean |
beforeOrEquals(java.util.Date clickdate,
java.util.Date end)
Returns true if the clickdate is equals or before the end date.
|
static boolean |
between(java.util.Date clickdate,
Range<java.util.Date> range,
boolean startInclusive,
boolean endInclusive)
Returns true if the clickdate is inside the given range.
|
static boolean |
betweenDaysOnly(java.util.Date clickdate,
Range<java.util.Date> range,
boolean startInclusive,
boolean endInclusive) |
static java.util.Date |
combineDate(java.util.Date date1,
java.util.Date date2)
Make a new Date from the date part of date1 and time part of date2
|
static int |
compareTime(java.util.Date date1,
java.util.Date date2)
See if date1 if before date2 in hours/minutes only.
|
static java.util.Date |
convertDateToUserTimezone(java.util.Date d,
java.util.Locale userLocale,
java.util.TimeZone userTimeZone)
Returns the date in user timezone and locale
|
static double |
convertToMinutes(double time,
java.lang.String uom)
convert a time to number of minutes based on the unit of measure.
The uom can be one of these, MINUTES HOURS DAYS |
static double |
durationBetweenTwoDates(java.util.Date startTime,
java.util.Date endTime)
Calculate the duration between two dates.
|
static java.lang.String |
formatDate(java.util.Date date)
Formats a given date that according to the U.S.
|
static java.util.Date |
getDate(java.util.Date date)
Get the date with hour/minute/second/millisecond stripped
|
static java.util.Date |
getDate(java.util.Date date,
java.util.TimeZone currentTimeZone,
java.util.TimeZone newTimeZone)
Converts a date from one Time Zone to another.
|
static java.util.Date |
getDateHourMinute(java.util.Date date)
Trims a
Date to the start of the day |
static java.util.Date |
getEndOfDayDate(java.util.Date date)
Get the date with hour/minute/second/millisecond maxed out
|
static java.util.Date |
getFirstDayWeek(java.util.Date date)
Returns first day of the week.
|
static java.util.Date |
getMaxDate(java.util.Date d1,
java.util.Date d2)
Returns the maximum of two dates.
|
static java.util.Date |
getMinDate(java.util.Date d1,
java.util.Date d2)
Returns the minimum of two dates.
|
static java.util.Date |
getNextDayAfter(java.util.Date date,
int day)
Get next
|
static int |
getOffset(int currentOffset,
int newOffset) |
static java.util.Set<DateRange> |
mergeDates(java.util.Collection<? extends Range<java.util.Date>> set) |
static java.util.Set<DateRange> |
mergeDates(java.util.Collection<? extends Range<java.util.Date>> set1,
java.util.Collection<? extends Range<java.util.Date>> set2) |
static java.util.Date |
moveDate(java.util.Date date,
java.util.TimeZone currentTimeZone,
java.util.TimeZone newTimeZone)
Converts a date from one Time Zone to another.
|
static int |
safeCompareTo(java.util.Date d1,
java.util.Date d2)
Performs a "compare" on two dates, accounting for null.
|
static boolean |
safeEquals(java.util.Date d1,
java.util.Date d2)
Performs and "equals" on two dates, accounting for null.
|
static int |
timeDiff(java.util.Date date1,
java.util.Date date2)
Time difference(in minutes) between date1 and date2 in hours/minutes.
|
static int |
timeDiffInDays(java.util.Date date1,
java.util.Date date2)
Time difference(in days) between date1 and date2 in days.
|
public static java.util.Set<DateRange> mergeDates(java.util.Collection<? extends Range<java.util.Date>> set1, java.util.Collection<? extends Range<java.util.Date>> set2)
public static java.util.Set<DateRange> mergeDates(java.util.Collection<? extends Range<java.util.Date>> set)
public static double convertToMinutes(double time, java.lang.String uom)
public static java.util.Date getDate(java.util.Date date)
public static java.util.Date getDateHourMinute(java.util.Date date)
Date
to the start of the dayin
- Date
Date
trimmed to the start of the daypublic static java.util.Date getEndOfDayDate(java.util.Date date)
public static java.util.Date addDays(java.util.Date date, int plusDays)
public static java.util.Date addHours(java.util.Date date, double hours)
public static java.util.Date addMinutes(java.util.Date date, int plusMinutes)
public static java.util.Date addSeconds(java.util.Date date, int plusSeconds)
public static int compareTime(java.util.Date date1, java.util.Date date2)
public static int timeDiff(java.util.Date date1, java.util.Date date2)
public static int timeDiffInDays(java.util.Date date1, java.util.Date date2)
public static java.util.Date combineDate(java.util.Date date1, java.util.Date date2)
public static java.util.Date getMaxDate(java.util.Date d1, java.util.Date d2)
public static java.util.Date getMinDate(java.util.Date d1, java.util.Date d2)
public static java.util.Date convertDateToUserTimezone(java.util.Date d, java.util.Locale userLocale, java.util.TimeZone userTimeZone)
l
- tz
- java.rmi.RemoteException
public static java.util.Date getDate(java.util.Date date, java.util.TimeZone currentTimeZone, java.util.TimeZone newTimeZone)
date
- currentTimeZone
- newTimeZone
- public static java.util.Date moveDate(java.util.Date date, java.util.TimeZone currentTimeZone, java.util.TimeZone newTimeZone)
date
- currentTimeZone
- newTimeZone
- public static int getOffset(int currentOffset, int newOffset)
public static java.lang.String formatDate(java.util.Date date)
date
- public static double durationBetweenTwoDates(java.util.Date startTime, java.util.Date endTime)
startDate
- endDate
- java.lang.Exception
public static boolean safeEquals(java.util.Date d1, java.util.Date d2)
d1
- d2
- public static int safeCompareTo(java.util.Date d1, java.util.Date d2)
d1
- d2
- public static boolean after(java.util.Date clickdate, java.util.Date start)
clickdate
- start
- public static boolean before(java.util.Date clickdate, java.util.Date end)
clickdate
- end
- public static boolean afterOrEquals(java.util.Date clickdate, java.util.Date start)
clickdate
- start
- public static boolean beforeOrEquals(java.util.Date clickdate, java.util.Date end)
clickdate
- end
- public static boolean between(java.util.Date clickdate, Range<java.util.Date> range, boolean startInclusive, boolean endInclusive)
clickdate
- range
- startInclusive
- endInclusive
- public static boolean betweenDaysOnly(java.util.Date clickdate, Range<java.util.Date> range, boolean startInclusive, boolean endInclusive)
public static java.util.Date getNextDayAfter(java.util.Date date, int day)
date
- - Current Dateday
- - Day of the week (Calendar.MONDAY, Calendar.TUESDAY, etc.)public static java.util.Date getFirstDayWeek(java.util.Date date)
date
-