Package com.jidesoft.utils
Class DateUtils
java.lang.Object
com.jidesoft.utils.DateUtils
DateUtils
contains many useful methods related to Date and Calendar.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Calendar
adjustDate
(Calendar calendar, int differenceInDay) Adjusts the Calendar to several days before or after the current date.static boolean
Checks if the calendar object is in the specified month, regardless of the year.static boolean
isAtQuarter
(Calendar cal, int quarter) Checks if the calendar object is in the specified quarter, regardless of the year.static boolean
isLastMonth
(Calendar cal) Checks if the calendar object is last month.static boolean
isLastQuarter
(Calendar cal) Checks if the calendar object is last quarter.static boolean
isLastWeek
(Calendar cal) Checks if the calendar object is last week.static boolean
isLastYear
(Calendar cal) Checks if the calendar object is last year.static boolean
isNextMonth
(Calendar cal) Checks if the calendar object is next month.static boolean
isNextQuarter
(Calendar cal) Checks if the calendar object is next quarter.static boolean
isNextWeek
(Calendar cal) Checks if the calendar object is next week.static boolean
isNextYear
(Calendar cal) Checks if the calendar object is next year.static boolean
isThisMonth
(Calendar cal) Checks if the calendar object is same month as today.static boolean
isThisQuarter
(Calendar cal) Checks if the calendar object is same quarter as today.static boolean
isThisWeek
(Calendar cal) Checks if the calendar object is same week as today.static boolean
isThisYear
(Calendar cal) Checks if the calendar object is same year as today.static boolean
Checks if the calendar object is same date as today.static boolean
isTomorrow
(Calendar cal) Checks if the calendar object is same date as tomorrow.static boolean
isYesterday
(Calendar cal) Checks if the calendar object is same date as yesterday.static Date
Deprecated.static Calendar
maxCalendars
(List<Calendar> calendars) Returns the maximum Calendar in the Calendar list.static Date
Returns the maximum Date in the Date list.static Date
Deprecated.replaced byminDates(java.util.List)
to comply with the new compilation regulation.static Calendar
minCalendars
(List<Calendar> calendars) Returns the minimum Calendar in the Calendar list.static Date
Returns the minimum Date in the Date list.static TimeRange
rangeCalendars
(List<Calendar> calendars) Returns the range of Calendars in the Calendar list.static TimeRange
rangeDates
(List<Date> dates) Returns the range of date in the Calendar list.
-
Constructor Details
-
DateUtils
public DateUtils()
-
-
Method Details
-
isToday
Checks if the calendar object is same date as today.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is the same date as today.
-
isThisWeek
Checks if the calendar object is same week as today.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is the same week as today.
-
isThisMonth
Checks if the calendar object is same month as today.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is the same month as today.
-
isThisQuarter
Checks if the calendar object is same quarter as today.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is the same quarter as today.
-
isThisYear
Checks if the calendar object is same year as today.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is the same year as today.
-
isYesterday
Checks if the calendar object is same date as yesterday.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is the same date as yesterday.
-
isLastWeek
Checks if the calendar object is last week.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is last week.
-
isLastMonth
Checks if the calendar object is last month.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is last month.
-
isLastQuarter
Checks if the calendar object is last quarter.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is last quarter.
-
isLastYear
Checks if the calendar object is last year.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is last year.
-
isTomorrow
Checks if the calendar object is same date as tomorrow.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is the same date as tomorrow.
-
isNextWeek
Checks if the calendar object is next week.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is next week.
-
isNextMonth
Checks if the calendar object is next month.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is next month.
-
isNextQuarter
Checks if the calendar object is next quarter.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is next quarter.
-
isNextYear
Checks if the calendar object is next year.- Parameters:
cal
- the calendar object- Returns:
- true if the calendar object is next year.
-
isAtMonth
Checks if the calendar object is in the specified month, regardless of the year.- Parameters:
cal
- the calendar object.month
- the month, starting from 0 for January. You can use the value defined in Calendar such as Calendar.JANUARY, Calendar.FEBRUARY, etc.- Returns:
- true if the calendar object is the specified month.
-
isAtQuarter
Checks if the calendar object is in the specified quarter, regardless of the year.- Parameters:
cal
- the calendar object.quarter
- the quarter, starting from 1 for the first quarter (including January, February, and March).- Returns:
- true if the calendar object is the specified quarter.
-
adjustDate
Adjusts the Calendar to several days before or after the current date.- Parameters:
calendar
- the Calendar object to be adjusted.differenceInDay
- the difference in days. It accepts both position and negative number.- Returns:
- the calendar after the adjustment. It should always be the same instance as the calendar parameter.
-
min
Deprecated.replaced byminDates(java.util.List)
to comply with the new compilation regulation. We have to delete the min(List) in releases earlier than 2.9.4 due to the same reason. Returns the minimum Date in the Date list.- Parameters:
dates
- the list of Date to calculate the minimum.- Returns:
- the minimum date in the Date list.
-
max
Deprecated.replaced bymaxDates(java.util.List)
to comply with the new compilation regulation. We have to delete the max(List) in releases earlier than 2.9.4 due to the same reason. Returns the maximum Date in the Date list.- Parameters:
dates
- the list of Date to calculate the maximum.- Returns:
- the maximum date in the Date list.
-
minDates
Returns the minimum Date in the Date list.- Parameters:
dates
- the list of Date to calculate the minimum.- Returns:
- the minimum date in the Date list.
-
maxDates
Returns the maximum Date in the Date list.- Parameters:
dates
- the list of Date to calculate the maximum.- Returns:
- the maximum date in the Date list.
-
rangeDates
Returns the range of date in the Calendar list.- Parameters:
dates
- the list of Dates to calculate the maximum.- Returns:
- the range date in the Calendar list.
-
minCalendars
Returns the minimum Calendar in the Calendar list.- Parameters:
calendars
- the list of Calendar to calculate the minimum.- Returns:
- the minimum calendar in the Calendar list.
-
maxCalendars
Returns the maximum Calendar in the Calendar list.- Parameters:
calendars
- the list of Calendar to calculate the maximum.- Returns:
- the maximum calendar in the Calendar list.
-
rangeCalendars
Returns the range of Calendars in the Calendar list.- Parameters:
calendars
- the list of Calendar to calculate the maximum.- Returns:
- the range of calendars in the Calendar list.
-
maxDates(java.util.List)
to comply with the new compilation regulation.