|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.hrodberaht.directus.util.DateUtil
public final class DateUtil
Simple Java Utils
| Method Summary | |
|---|---|
static boolean |
after(java.util.Date theDate,
java.util.Date compare)
Compares if the date is after the compare date |
static boolean |
before(java.util.Date theDate,
java.util.Date compare)
Compares if the date is after the compare date |
static boolean |
equals(java.util.Date date1,
java.util.Date date2)
A different version than the java version of Date.equals, it does not care about type. |
static java.lang.String |
formatDate(java.util.Date date)
Formats the date according to selected locale pattern for short dates (no time). |
static java.lang.String |
formatDate(java.util.Date date,
java.lang.String pattern)
Formats the date according to set pattern, see normal dateformattingrules for pattern |
static java.lang.String |
formatDateTime(java.util.Date date)
Formats the date according to selected locale pattern for long dates (date & time). |
static boolean |
formattedDateEquals(java.util.Date date1,
java.util.Date date2,
java.lang.String pattern)
Reformat the dates according to pattern and then calls equals on them. |
static java.lang.String |
formatTimeZone(java.util.Date theDate)
Formatted version of selected locale (DateUtil#locale) timezone |
static java.util.Date |
getNow()
This is very useful if a developer needs to override what the time is for specific tests. |
static boolean |
isBetween(java.util.Date theDate,
java.util.Date fromDate,
java.util.Date toDate)
Date is considered to be in between if it is equals to or less than toDate or equal to or more than fromDate |
static boolean |
isFirstInMonth(java.util.Date date)
Is the date the first in the month of its own definition. |
static boolean |
isFirstInThisMonth(java.util.Date date)
Is the date the first in the current month, uses DateUtil.getNow for compare |
static boolean |
isLastInMonth(java.util.Date date)
Is the date the last in the month of its own definition. |
static boolean |
isLessOrEqual(java.util.Date theDate,
java.util.Date compare)
Compare if the dates are less or equal |
static boolean |
isMoreOrEqual(java.util.Date theDate,
java.util.Date compare)
Compare if the dates are more or equal |
static java.util.Date |
parseDate(java.lang.String date,
java.lang.String pattern)
Parse a date according to the provided pattern |
static java.util.Date |
parseSimpleDate(java.lang.String date)
A simple parser that can find out what date/time type the selected inputted string is of and tries to parse that. |
static java.util.Date |
rollDays(java.util.Date date,
int days)
Uses a Calendar.add(Calendar.DAY_OF_YEAR, hours), but is usable from a Date as input. |
static java.util.Date |
rollHours(java.util.Date date,
int hours)
Uses a Calendar.add(Calendar.HOUR_OF_DAY, hours), but is usable from a Date as input. |
static java.util.Date |
rollMonth(java.util.Date date,
int months)
Uses a Calendar.add(Calendar.MONTH, hours), but is usable from a Date as input. |
static void |
setLocale(java.util.Locale locale)
Utility method to change the locale of the DateUtil, affects the entire server as its static Will call DateUtil.updateFormatPatterns after setting the locale |
static java.util.Date |
setTimeToActualMaximum(java.util.Date date)
Sets the maximum possible time (hours, minutes, seconds, millis) and returns as a new instance of date. |
static java.util.Date |
setTimeToActualMinimum(java.util.Date date)
Sets the minimum possible time (hours, minutes, seconds, millis) and returns as a new instance of date. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void setLocale(java.util.Locale locale)
locale - the locale to change to
public static boolean isLessOrEqual(java.util.Date theDate,
java.util.Date compare)
theDate - the datecompare - the compare date for compare
public static boolean isMoreOrEqual(java.util.Date theDate,
java.util.Date compare)
theDate - the datecompare - the compare date for compare
public static boolean after(java.util.Date theDate,
java.util.Date compare)
theDate - base date for comparecompare - the compare date for compare
public static boolean before(java.util.Date theDate,
java.util.Date compare)
theDate - base date for comparecompare - the compare date for compare
public static java.util.Date parseDate(java.lang.String date,
java.lang.String pattern)
date - the string to use for parsingpattern - the pattern to use for parsing
public static boolean formattedDateEquals(java.util.Date date1,
java.util.Date date2,
java.lang.String pattern)
date1 - date for comparedate2 - date for comparepattern - to apply before compare
public static boolean equals(java.util.Date date1,
java.util.Date date2)
date1 - date for comparedate2 - date for compare
public static java.util.Date parseSimpleDate(java.lang.String date)
date - the string to test for parsing
public static java.lang.String formatTimeZone(java.util.Date theDate)
- theDate - date to check timezone for
public static java.lang.String formatDate(java.util.Date date)
date - date for formatting
SimpleDateFormat.toLocalizedPattern()public static java.lang.String formatDateTime(java.util.Date date)
date - date for formatting
SimpleDateFormat.toLocalizedPattern()
public static java.lang.String formatDate(java.util.Date date,
java.lang.String pattern)
date - date for formattingpattern - intended pattern
for patterns
public static java.util.Date rollDays(java.util.Date date,
int days)
date - date to rolldays - amount of days to roll
Calendar.add(int, int)
public static java.util.Date rollMonth(java.util.Date date,
int months)
date - date to rollmonths - amount of months to roll
Calendar.add(int, int)
public static java.util.Date rollHours(java.util.Date date,
int hours)
date - date to rollhours - amount of hours to roll
Calendar.add(int, int)public static java.util.Date setTimeToActualMinimum(java.util.Date date)
date - date for minimum time settings
public static java.util.Date setTimeToActualMaximum(java.util.Date date)
date - date for maximum time settings
public static java.util.Date getNow()
TestUtilDateUtil.setNowDate(java.util.Date)public static boolean isFirstInThisMonth(java.util.Date date)
date -
getNow()public static boolean isFirstInMonth(java.util.Date date)
date -
public static boolean isLastInMonth(java.util.Date date)
date -
public static boolean isBetween(java.util.Date theDate,
java.util.Date fromDate,
java.util.Date toDate)
theDate - is the date for comparisonfromDate - is the start valuetoDate - is the end value
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||