public class CalendarUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ONE_DAY |
static int |
ONE_HOUR |
static int |
ONE_MINUTE |
static int |
THREE_HOURS |
Constructor and Description |
---|
CalendarUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areEqual(Date current,
Date date)
Checks the given dates for being equal.
|
static void |
endOfDay(Calendar calendar)
Adjust the given calendar to the last millisecond of the specified date.
|
static Date |
endOfDay(Calendar calendar,
Date date)
Adjust the given calendar to the last millisecond of the given date.
|
static void |
endOfMonth(Calendar calendar)
Adjusts the calendar to the end of the current month.
|
static void |
endOfWeek(Calendar calendar)
Adjusts the calendar to the end of the current week.
|
static Date |
endOfWeek(Calendar calendar,
Date date)
Adjusts the calendar to the end of the current week.
|
static Date |
getEndOfDST(Calendar calendar)
Adjusts the Calendar to the end of the day of the last day in DST in the
current year or unchanged if not using DST.
|
static Date |
getStartOfDST(Calendar calendar)
Adjusts the Calendar to the end of the day of the first day in DST in the
current year or unchanged if not using DST.
|
static boolean |
isEndOfDay(Calendar calendar)
Returns a boolean indicating if the given calendar represents the
end of a day (in the calendar's time zone).
|
static boolean |
isEndOfMonth(Calendar calendar)
Returns a boolean indicating if the given calendar represents the
end of a month (in the calendar's time zone).
|
static boolean |
isEndOfWeek(Calendar calendar)
Returns a boolean indicating if the given calendar represents the
end of a week (in the calendar's time zone).
|
static boolean |
isSameDay(Calendar today,
Date now)
Returns a boolean indicating whether the given Date is the same day as
the day in the calendar.
|
static boolean |
isStartOfDay(Calendar calendar)
Returns a boolean indicating if the given calendar represents the
start of a day (in the calendar's time zone).
|
static boolean |
isStartOfMonth(Calendar calendar)
Returns a boolean indicating if the given calendar represents the
start of a month (in the calendar's time zone).
|
static boolean |
isStartOfWeek(Calendar calendar)
Returns a boolean indicating if the given calendar represents the
start of a month (in the calendar's time zone).
|
static void |
startOfDay(Calendar calendar)
Adjust the given calendar to the first millisecond of the current day.
|
static Date |
startOfDay(Calendar calendar,
Date date)
Adjust the given calendar to the first millisecond of the given date.
|
static void |
startOfMonth(Calendar calendar)
Adjusts the calendar to the start of the current month.
|
static void |
startOfWeek(Calendar calendar)
Adjusts the calendar to the start of the current week.
|
static Date |
startOfWeek(Calendar calendar,
Date date)
Adjusts the calendar to the start of the current week.
|
public static final int ONE_MINUTE
public static final int ONE_HOUR
public static final int THREE_HOURS
public static final int ONE_DAY
public static Date getEndOfDST(Calendar calendar)
calendar
- the calendar to adjustpublic static Date getStartOfDST(Calendar calendar)
Note: the start of the day of the first day in DST is ill-defined!
calendar
- the calendar to adjustpublic static boolean isStartOfDay(Calendar calendar)
calendar
- the calendar to check.public static boolean isEndOfDay(Calendar calendar)
calendar
- the calendar to check.public static boolean isStartOfMonth(Calendar calendar)
calendar
- the calendar to check.public static boolean isEndOfMonth(Calendar calendar)
calendar
- the calendar to check.public static boolean isStartOfWeek(Calendar calendar)
calendar
- the calendar to check.public static boolean isEndOfWeek(Calendar calendar)
calendar
- the calendar to check.public static void startOfWeek(Calendar calendar)
calendar
- the calendar to adjust.public static void endOfWeek(Calendar calendar)
calendar
- the calendar to adjust.public static Date endOfWeek(Calendar calendar, Date date)
calendar
- calendar to adjust.date
- the Date to use.public static Date startOfWeek(Calendar calendar, Date date)
calendar
- calendar to adjust.date
- the Date to use.public static void startOfMonth(Calendar calendar)
calendar
- public static void endOfMonth(Calendar calendar)
calendar
- public static Date startOfDay(Calendar calendar, Date date)
calendar
- calendar to adjust.date
- the Date to use.public static Date endOfDay(Calendar calendar, Date date)
calendar
- calendar to adjust.date
- the Date to use.public static void startOfDay(Calendar calendar)
calendar
- calendar to adjust.public static void endOfDay(Calendar calendar)
calendar
- calendar to adjust.public static boolean areEqual(Date current, Date date)
current
- one of the dates to comparedate
- the otherr of the dates to comparepublic static boolean isSameDay(Calendar today, Date now)
today
- the Calendar representing a date, must not be null.now
- the date to compare to, must not be nullCopyright © 2013. All Rights Reserved.