public class DateUtils extends Object
DateUtils
contains many useful methods related to Date and Calendar.Constructor and Description |
---|
DateUtils() |
Modifier and Type | Method and Description |
---|---|
static Calendar |
adjustDate(Calendar calendar,
int differenceInDay)
Adjusts the Calendar to several days before or after the current date.
|
static boolean |
isAtMonth(Calendar cal,
int month)
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 |
isToday(Calendar cal)
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 |
max(List<Date> dates)
Deprecated.
replaced by
maxDates(java.util.List) to comply with the new compilation regulation. We
have to delete the max(List |
static Calendar |
maxCalendars(List<Calendar> calendars)
Returns the maximum Calendar in the Calendar list.
|
static Date |
maxDates(List<Date> dates)
Returns the maximum Date in the Date list.
|
static Date |
min(List<Date> dates)
Deprecated.
replaced by
minDates(java.util.List) to comply with the new compilation regulation. We
have to delete the min(List |
static Calendar |
minCalendars(List<Calendar> calendars)
Returns the minimum Calendar in the Calendar list.
|
static Date |
minDates(List<Date> dates)
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.
|
public static boolean isToday(Calendar cal)
cal
- the calendar objectpublic static boolean isThisWeek(Calendar cal)
cal
- the calendar objectpublic static boolean isThisMonth(Calendar cal)
cal
- the calendar objectpublic static boolean isThisQuarter(Calendar cal)
cal
- the calendar objectpublic static boolean isThisYear(Calendar cal)
cal
- the calendar objectpublic static boolean isYesterday(Calendar cal)
cal
- the calendar objectpublic static boolean isLastWeek(Calendar cal)
cal
- the calendar objectpublic static boolean isLastMonth(Calendar cal)
cal
- the calendar objectpublic static boolean isLastQuarter(Calendar cal)
cal
- the calendar objectpublic static boolean isLastYear(Calendar cal)
cal
- the calendar objectpublic static boolean isTomorrow(Calendar cal)
cal
- the calendar objectpublic static boolean isNextWeek(Calendar cal)
cal
- the calendar objectpublic static boolean isNextMonth(Calendar cal)
cal
- the calendar objectpublic static boolean isNextQuarter(Calendar cal)
cal
- the calendar objectpublic static boolean isNextYear(Calendar cal)
cal
- the calendar objectpublic static boolean isAtMonth(Calendar cal, int month)
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.public static boolean isAtQuarter(Calendar cal, int quarter)
cal
- the calendar object.quarter
- the quarter, starting from 1 for the first quarter (including January, February, and March).public static Calendar adjustDate(Calendar calendar, int differenceInDay)
calendar
- the Calendar object to be adjusted.differenceInDay
- the difference in days. It accepts both position and negative number.@Deprecated public static Date min(List<Date> dates)
minDates(java.util.List)
to comply with the new compilation regulation. We
have to delete the min(Listdates
- the list of Date to calculate the minimum.@Deprecated public static Date max(List<Date> dates)
maxDates(java.util.List)
to comply with the new compilation regulation. We
have to delete the max(Listdates
- the list of Date to calculate the maximum.public static Date minDates(List<Date> dates)
dates
- the list of Date to calculate the minimum.public static Date maxDates(List<Date> dates)
dates
- the list of Date to calculate the maximum.public static TimeRange rangeDates(List<Date> dates)
dates
- the list of Dates to calculate the maximum.public static Calendar minCalendars(List<Calendar> calendars)
calendars
- the list of Calendar to calculate the minimum.public static Calendar maxCalendars(List<Calendar> calendars)
calendars
- the list of Calendar to calculate the maximum.