public class DateUtils
extends java.lang.Object
DateUtils
contains many useful methods related to Date and Calendar.Constructor and Description |
---|
DateUtils() |
Modifier and Type | Method and Description |
---|---|
static java.util.Calendar |
adjustDate(java.util.Calendar calendar,
int differenceInDay)
Adjusts the Calendar to several days before or after the current date.
|
static boolean |
isAtMonth(java.util.Calendar cal,
int month)
Checks if the calendar object is in the specified month, regardless of the year.
|
static boolean |
isAtQuarter(java.util.Calendar cal,
int quarter)
Checks if the calendar object is in the specified quarter, regardless of the year.
|
static boolean |
isLastMonth(java.util.Calendar cal)
Checks if the calendar object is last month.
|
static boolean |
isLastQuarter(java.util.Calendar cal)
Checks if the calendar object is last quarter.
|
static boolean |
isLastWeek(java.util.Calendar cal)
Checks if the calendar object is last week.
|
static boolean |
isLastYear(java.util.Calendar cal)
Checks if the calendar object is last year.
|
static boolean |
isNextMonth(java.util.Calendar cal)
Checks if the calendar object is next month.
|
static boolean |
isNextQuarter(java.util.Calendar cal)
Checks if the calendar object is next quarter.
|
static boolean |
isNextWeek(java.util.Calendar cal)
Checks if the calendar object is next week.
|
static boolean |
isNextYear(java.util.Calendar cal)
Checks if the calendar object is next year.
|
static boolean |
isThisMonth(java.util.Calendar cal)
Checks if the calendar object is same month as today.
|
static boolean |
isThisQuarter(java.util.Calendar cal)
Checks if the calendar object is same quarter as today.
|
static boolean |
isThisWeek(java.util.Calendar cal)
Checks if the calendar object is same week as today.
|
static boolean |
isThisYear(java.util.Calendar cal)
Checks if the calendar object is same year as today.
|
static boolean |
isToday(java.util.Calendar cal)
Checks if the calendar object is same date as today.
|
static boolean |
isTomorrow(java.util.Calendar cal)
Checks if the calendar object is same date as tomorrow.
|
static boolean |
isYesterday(java.util.Calendar cal)
Checks if the calendar object is same date as yesterday.
|
static java.util.Date |
maxX(java.util.List<java.util.Date> dates)
Returns the maximum Date in the Date list.
|
static java.util.Calendar |
maxY(java.util.List<java.util.Calendar> calendars)
Returns the maximum Calendar in the Calendar list.
|
static java.util.Date |
minX(java.util.List<java.util.Date> dates)
Returns the minimum Date in the Date list.
|
static java.util.Calendar |
minY(java.util.List<java.util.Calendar> calendars)
Returns the minimum Calendar in the Calendar list.
|
public static boolean isToday(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isThisWeek(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isThisMonth(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isThisQuarter(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isThisYear(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isYesterday(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isLastWeek(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isLastMonth(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isLastQuarter(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isLastYear(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isTomorrow(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isNextWeek(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isNextMonth(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isNextQuarter(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isNextYear(java.util.Calendar cal)
cal
- the calendar objectpublic static boolean isAtMonth(java.util.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(java.util.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 java.util.Calendar adjustDate(java.util.Calendar calendar, int differenceInDay)
calendar
- the Calendar object to be adjusted.differenceInDay
- the difference in days. It accepts both position and negative number.public static java.util.Date minX(java.util.List<java.util.Date> dates)
dates
- the list of Date to calculate the minimum.public static java.util.Date maxX(java.util.List<java.util.Date> dates)
dates
- the list of Date to calculate the maximum.public static java.util.Calendar minY(java.util.List<java.util.Calendar> calendars)
calendars
- the list of Calendar to calculate the minimum.public static java.util.Calendar maxY(java.util.List<java.util.Calendar> calendars)
calendars
- the list of Calendar to calculate the maximum.