|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object consciouscode.util.Dates
public final class Dates
Utility class containing date manipulation routines.
Calendar
,
Date
Constructor Summary | |
---|---|
Dates()
|
Method Summary | |
---|---|
static int |
computeAge(Date fromDate)
Determines the age, in years, since the fromDate
until the present date. |
static int |
computeAge(Date fromDate,
Calendar calendar)
Determines the age, in years, since the fromDate
until the present date. |
static Date |
computeRelativeDay(Date originalDate,
long dayDifference)
Create a new Date object whose time is a given number of days away from the given date. |
static boolean |
dateIsValid(int year,
int month,
int day,
Calendar calendar)
Determine whether the proposed date actually exists. |
static Date |
makeTodaysDate()
Create a new Date instance with the current date, but all fields smaller than Day of Month set to zero. |
static Date |
makeTodaysDate(Calendar calendar)
Create a new Date instance with the current date, but all fields smaller than Day of Month set to zero. |
static Date |
makeValidDate(int year,
int month,
int day)
Create a new Date instance representing the given calendar date. |
static Date |
makeValidDate(int year,
int month,
int day,
Calendar calendar)
Create a new Date instance representing the given calendar date. |
static Date |
truncateToDay(Date date)
Return a Date similar to the given date ,
but with all fields smaller than Day of Month set to zero. |
static Date |
truncateToDay(Date date,
Calendar calendar)
Return a Date similar to the given date ,
but with all fields smaller than Day of Month set to zero. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Dates()
Method Detail |
---|
public static boolean dateIsValid(int year, int month, int day, Calendar calendar)
month
- is one-based!calendar
- will be set to the proposed date if it exists,
or to an indeterminate time if the proposed date does not exist.
true
when the proposed date exists in the
calendar. In addition, if the date exists, calendar
will
be set to contain it.public static Date makeValidDate(int year, int month, int day, Calendar calendar)
month
- is one-based!calendar
- will be set to the proposed date if it exists,
or to an indeterminate time if the proposed date does not exist.
null
if the
proposed date does not actually exist (e.g., December 32).public static Date makeValidDate(int year, int month, int day)
makeValidDate(int, int, int, Calendar)
,
but using the default Calendar.
month
- is one-based!
null
if the
proposed date does not actually exist (e.g., December 32).public static Date truncateToDay(Date date, Calendar calendar)
Date
similar to the given date
,
but with all fields smaller than Day of Month set to zero.
calendar
- will be set to the truncated date.public static Date truncateToDay(Date date)
Date
similar to the given date
,
but with all fields smaller than Day of Month set to zero.
This is the same as truncateToDay(Date, Calendar)
, but using
the default Calendar.
public static Date makeTodaysDate(Calendar calendar)
Note that this is not the same as new Date()
since that will be accurate to the current millisecond.
calendar
- will be set to the today's date,
with all fields smaller than Day of Month set to zero.public static Date makeTodaysDate()
Note that this is not the same as new Date()
since that will be accurate to the current millisecond.
makeTodaysDate(Calendar)
, but using the
default Calendar.
public static Date computeRelativeDay(Date originalDate, long dayDifference)
originalDate
- the starting point in time.dayDifference
- the number of days to roll into the future
(if positive) or past (if negative).public static int computeAge(Date fromDate)
fromDate
until the present date. This is the same as
computeAge(Date, Calendar)
, using the default Calendar.
public static int computeAge(Date fromDate, Calendar calendar)
fromDate
until the present date.
calendar
- will be set to fromDate
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |