public class CalendarUtils
extends java.lang.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(java.util.Date current,
java.util.Date date)
Checks the given dates for being equal.
|
static void |
endOfDay(java.util.Calendar calendar)
Adjust the given calendar to the last millisecond of the specified date.
|
static java.util.Date |
endOfDay(java.util.Calendar calendar,
java.util.Date date)
Adjust the given calendar to the last millisecond of the given date.
|
static void |
endOfMonth(java.util.Calendar calendar)
Adjusts the calendar to the end of the current month.
|
static void |
endOfWeek(java.util.Calendar calendar)
Adjusts the calendar to the end of the current week.
|
static java.util.Date |
endOfWeek(java.util.Calendar calendar,
java.util.Date date)
Adjusts the calendar to the end of the current week.
|
static java.util.Date |
getEndOfDST(java.util.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 java.util.Date |
getStartOfDST(java.util.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(java.util.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(java.util.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(java.util.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(java.util.Calendar today,
java.util.Date now)
Returns a boolean indicating whether the given Date is the same day as
the day in the calendar.
|
static boolean |
isStartOfDay(java.util.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(java.util.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(java.util.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(java.util.Calendar calendar)
Adjust the given calendar to the first millisecond of the current day.
|
static java.util.Date |
startOfDay(java.util.Calendar calendar,
java.util.Date date)
Adjust the given calendar to the first millisecond of the given date.
|
static void |
startOfMonth(java.util.Calendar calendar)
Adjusts the calendar to the start of the current month.
|
static void |
startOfWeek(java.util.Calendar calendar)
Adjusts the calendar to the start of the current week.
|
static java.util.Date |
startOfWeek(java.util.Calendar calendar,
java.util.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 java.util.Date getEndOfDST(java.util.Calendar calendar)
calendar
- the calendar to adjustpublic static java.util.Date getStartOfDST(java.util.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(java.util.Calendar calendar)
calendar
- the calendar to check.public static boolean isEndOfDay(java.util.Calendar calendar)
calendar
- the calendar to check.public static boolean isStartOfMonth(java.util.Calendar calendar)
calendar
- the calendar to check.public static boolean isEndOfMonth(java.util.Calendar calendar)
calendar
- the calendar to check.public static boolean isStartOfWeek(java.util.Calendar calendar)
calendar
- the calendar to check.public static boolean isEndOfWeek(java.util.Calendar calendar)
calendar
- the calendar to check.public static void startOfWeek(java.util.Calendar calendar)
calendar
- the calendar to adjust.public static void endOfWeek(java.util.Calendar calendar)
calendar
- the calendar to adjust.public static java.util.Date endOfWeek(java.util.Calendar calendar, java.util.Date date)
calendar
- calendar to adjust.date
- the Date to use.public static java.util.Date startOfWeek(java.util.Calendar calendar, java.util.Date date)
calendar
- calendar to adjust.date
- the Date to use.public static void startOfMonth(java.util.Calendar calendar)
calendar
- public static void endOfMonth(java.util.Calendar calendar)
calendar
- public static java.util.Date startOfDay(java.util.Calendar calendar, java.util.Date date)
calendar
- calendar to adjust.date
- the Date to use.public static java.util.Date endOfDay(java.util.Calendar calendar, java.util.Date date)
calendar
- calendar to adjust.date
- the Date to use.public static void startOfDay(java.util.Calendar calendar)
calendar
- calendar to adjust.public static void endOfDay(java.util.Calendar calendar)
calendar
- calendar to adjust.public static boolean areEqual(java.util.Date current, java.util.Date date)
current
- one of the dates to comparedate
- the otherr of the dates to comparepublic static boolean isSameDay(java.util.Calendar today, java.util.Date now)
today
- the Calendar representing a date, must not be null.now
- the date to compare to, must not be null