|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jdesktop.swingx.calendar.DateUtils
public class DateUtils
Utility methods for Date manipulation.
This utility class is replaced by CalendarUtils because day related manipulation are meaningfull relative to a Calendar only. Always doing so against the default calendar instance isn't enough. PENDING JW: move the missing ops. Volunteers, please! Once done, this will be deprecated.
| Constructor Summary | |
|---|---|
DateUtils()
|
|
| Method Summary | |
|---|---|
static long |
addDays(long time,
int amount)
Adds amount days to time and returns
the resulting time. |
static Date |
endOfDay(Date date)
Returns the last millisecond of the specified date. |
static long |
endOfDayInMillis(long date)
Returns the last millisecond of the specified date. |
static int |
getDayOfWeek(long date)
Returns the day of the week. |
static int |
getDaysDiff(long t1,
long t2)
Returns the number of days difference between t1 and
t2. |
static int |
getDaysDiff(long t1,
long t2,
boolean checkOverflow)
Returns the number of days difference between t1 and
t2. |
static long |
getEndOfMonth(long date)
Returns the date corresponding to the end of the month. |
static long |
getNextDay(long date,
int startOfWeek)
Returns the first day after date that has the
day of week matching startOfWeek. |
static long |
getNextMonth(long date)
Returns the next month. |
static long |
getPreviousDay(long date,
int startOfWeek)
Returns the first day before date that has the
day of week matching startOfWeek. |
static long |
getPreviousMonth(long date)
Returns the previous month. |
static long |
getStartOfMonth(long date)
Returns the date corresponding to the start of the month. |
static boolean |
isFirstOfMonth(long date)
Check, whether the date passed in is the first day of the month. |
static boolean |
isFirstOfYear(long date)
Check, whether the date passed in is the first day of the year. |
static Date |
nextDay(Date date)
Returns the day after date. |
static long |
nextDay(long date)
Returns the day after date. |
static long |
nextWeek(long date)
Returns the week after date. |
static long |
previousDay(long date)
Returns the day before date. |
static long |
previousWeek(long date)
Returns the week before date. |
static Date |
startOfDay(Date date)
Returns a new Date with the hours, milliseconds, seconds and minutes set to 0. |
static long |
startOfDayInMillis(long date)
Returns day in millis with the hours, milliseconds, seconds and minutes set to 0. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DateUtils()
| Method Detail |
|---|
public static Date endOfDay(Date date)
date - Date to calculate end of day from
datepublic static Date startOfDay(Date date)
date - Date used in calculating start of day
datepublic static long startOfDayInMillis(long date)
date - long used in calculating start of day
datepublic static long endOfDayInMillis(long date)
date - long to calculate end of day from
datepublic static Date nextDay(Date date)
date.
date - Date used in calculating next day
date.
public static long addDays(long time,
int amount)
amount days to time and returns
the resulting time.
time - Base timeamount - Amount of increment.
public static long nextDay(long date)
date.
date - Date used in calculating next day
date.public static long nextWeek(long date)
date.
date - Date used in calculating next week
date.
public static int getDaysDiff(long t1,
long t2,
boolean checkOverflow)
t1 and
t2.
t1 - Time 1t2 - Time 2checkOverflow - indicates whether to check for overflow
start and end
public static int getDaysDiff(long t1,
long t2)
t1 and
t2.
t1 - Time 1t2 - Time 2
start and endpublic static boolean isFirstOfYear(long date)
date - date to check in millis
true if date corresponds to the first
day of a yearDate.getTime()public static boolean isFirstOfMonth(long date)
date - date to check in millis
true if date corresponds to the first
day of a monthDate.getTime()public static long previousDay(long date)
date.
date - Date used in calculating previous day
date.public static long previousWeek(long date)
date.
date - Date used in calculating previous week
date.
public static long getPreviousDay(long date,
int startOfWeek)
date that has the
day of week matching startOfWeek. For example, if you
want to find the previous monday relative to date you
would call getPreviousDay(date, Calendar.MONDAY).
date - Base datestartOfWeek - Calendar constant correspoding to start of week.
public static long getNextDay(long date,
int startOfWeek)
date that has the
day of week matching startOfWeek. For example, if you
want to find the next monday relative to date you
would call getPreviousDay(date, Calendar.MONDAY).
date - Base datestartOfWeek - Calendar constant correspoding to start of week.
public static long getPreviousMonth(long date)
date - Base date
public static long getNextMonth(long date)
date - Base date
public static long getStartOfMonth(long date)
date - Base date
public static long getEndOfMonth(long date)
date - Base date
public static int getDayOfWeek(long date)
date - date
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||