public final class DateUtility extends Object
| Modifier and Type | Field and Description |
|---|---|
static Date |
FIRST_DATE
First date supported by Microsoft Project: January 01 00:00:00 1984.
|
static Date |
LAST_DATE
Last date supported by Microsoft Project: Friday December 31 23:59:00 2049.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
compare(Date d1,
Date d2)
Compare two dates, handling null values.
|
static int |
compare(Date startDate,
Date endDate,
Date targetDate)
This method compares a target date with a date range.
|
static int |
compare(Date startDate,
Date endDate,
long targetDate)
This method compares a target date with a date range.
|
static Date |
getCanonicalTime(Date date)
This method resets the date part of a date time value to
a standard date (1/1/1).
|
static Date |
getDateFromLong(long date)
Creates a date from the equivalent long value.
|
static Date |
getDayEndDate(Date date)
Returns a new Date instance whose value
represents the end of the day (i.e.
|
static Date |
getDayStartDate(Date date)
Returns a new Date instance whose value
represents the start of the day (i.e.
|
static Date |
getTime(int hour,
int minutes)
Create a Date instance representing a specific time.
|
static Date |
getTimestampFromLong(long timestamp)
Creates a timestamp from the equivalent long value.
|
static Duration |
getVariance(Task task,
Date date1,
Date date2,
TimeUnit format)
This utility method calculates the difference in working
time between two dates, given the context of a task.
|
static void |
setTime(Calendar cal,
Date time)
Given a date represented by a Calendar instance, set the time
component of the date based on the hours and minutes of the
time supplied by the Date instance.
|
static Date |
setTime(Date date,
Date canonicalTime)
Given a date represented by a Date instance, set the time
component of the date based on the hours and minutes of the
time supplied by the Date instance.
|
public static final Date FIRST_DATE
public static final Date LAST_DATE
public static Date getDayStartDate(Date date)
date - date to convertpublic static Date getDayEndDate(Date date)
date - date to convertpublic static Date getCanonicalTime(Date date)
date - date time valuepublic static int compare(Date startDate, Date endDate, Date targetDate)
startDate - range start dateendDate - range end datetargetDate - target datepublic static int compare(Date startDate, Date endDate, long targetDate)
startDate - range start dateendDate - range end datetargetDate - target date in millisecondspublic static int compare(Date d1, Date d2)
d1 - Date instanced2 - Date instancepublic static Duration getVariance(Task task, Date date1, Date date2, TimeUnit format)
task - parent taskdate1 - first datedate2 - second dateformat - required format for the resulting durationpublic static Date getDateFromLong(long date)
date - date expressed as a long integerpublic static Date getTimestampFromLong(long timestamp)
timestamp - timestamp expressed as a long integerpublic static Date getTime(int hour, int minutes)
hour - hour 0-23minutes - minutes 0-59public static void setTime(Calendar cal, Date time)
cal - Calendar instance representing the datetime - Date instance representing the time of daypublic static Date setTime(Date date, Date canonicalTime)
date - Date instance representing the datecanonicalTime - Date instance representing the time of dayCopyright © 2013. All Rights Reserved.