public final class CalendarUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addDays(java.util.Calendar calendar,
int days)
Add the given amount of days to the given calendar.
|
static void |
addHours(java.util.Calendar calendar,
int hours)
Add the given amount of hours to the given calendar.
|
static void |
addMillis(java.util.Calendar calendar,
int millis)
Add the given amount of millis to the given calendar.
|
static void |
addMinutes(java.util.Calendar calendar,
int minutes)
Add the given amount of minutes to the given calendar.
|
static void |
addMonths(java.util.Calendar calendar,
int months)
Add the given amount of months to the given calendar.
|
static void |
addSeconds(java.util.Calendar calendar,
int seconds)
Add the given amount of seconds to the given calendar.
|
static void |
addYears(java.util.Calendar calendar,
int years)
Add the given amount of years to the given calendar.
|
static int |
elapsedDays(java.util.Calendar before,
java.util.Calendar after)
Retrieve the amount of elapsed days between the two given calendars.
|
static int |
elapsedHours(java.util.Calendar before,
java.util.Calendar after)
Retrieve the amount of elapsed hours between the two given calendars.
|
static long |
elapsedMillis(java.util.Calendar before,
java.util.Calendar after)
Retrieve the amount of elapsed milliseconds between the two given calendars.
|
static int |
elapsedMinutes(java.util.Calendar before,
java.util.Calendar after)
Retrieve the amount of elapsed minutes between the two given calendars.
|
static int |
elapsedMonths(java.util.Calendar before,
java.util.Calendar after)
Retrieve the amount of elapsed months between the two given calendars.
|
static int |
elapsedSeconds(java.util.Calendar before,
java.util.Calendar after)
Retrieve the amount of elapsed seconds between the two given calendars.
|
static int[] |
elapsedTime(java.util.Calendar before,
java.util.Calendar after)
Calculate the total of elapsed time from years up to seconds between the two given calendars.
|
static int |
elapsedYears(java.util.Calendar before,
java.util.Calendar after)
Retrieve the amount of elapsed years between the two given calendars.
|
static java.util.Calendar |
getValidCalendar(int year,
int month,
int day)
Validate the actual date of the given date elements and returns a calendar instance based on
the given date elements.
|
static java.util.Calendar |
getValidCalendar(int year,
int month,
int day,
int hour,
int minute,
int second)
Validate the actual date of the given date elements and returns a calendar instance based on
the given date elements.
|
static boolean |
isValidDate(int year,
int month,
int day)
Checks whether the given day, month and year combination is a valid date or not.
|
static boolean |
isValidDate(int year,
int month,
int day,
int hour,
int minute,
int second)
Checks whether the given day, month, year, hour, minute and second combination is a valid
date or not.
|
static boolean |
isValidTime(int hour,
int minute,
int second)
Checks whether the given hour, minute and second combination is a valid time or not.
|
static boolean |
sameDay(java.util.Calendar one,
java.util.Calendar two)
Returns true if the two given calendars are dated on the same year, month and day.
|
static boolean |
sameHour(java.util.Calendar one,
java.util.Calendar two)
Returns true if the two given calendars are dated on the same year, month, day and
hour.
|
static boolean |
sameMinute(java.util.Calendar one,
java.util.Calendar two)
Returns true if the two given calendars are dated on the same year, month, day,
hour and minute.
|
static boolean |
sameMonth(java.util.Calendar one,
java.util.Calendar two)
Returns true if the two given calendars are dated on the same year and month.
|
static boolean |
sameSecond(java.util.Calendar one,
java.util.Calendar two)
Returns true if the two given calendars are dated on the same year, month, day,
hour, minute and second.
|
static boolean |
sameTime(java.util.Calendar one,
java.util.Calendar two)
Returns true if the two given calendars are dated on the same time.
|
static boolean |
sameYear(java.util.Calendar one,
java.util.Calendar two)
Returns true if the two given calendars are dated on the same year.
|
public static boolean isValidDate(int year, int month, int day)
year
- The year part of the date.month
- The month part of the date.day
- The day part of the date.public static boolean isValidTime(int hour, int minute, int second)
hour
- The hour part of the time.minute
- The minute part of the time.second
- The second part of the time.public static boolean isValidDate(int year, int month, int day, int hour, int minute, int second)
year
- The year part of the date.month
- The month part of the date.day
- The day part of the date.hour
- The hour part of the date.minute
- The minute part of the date.second
- The second part of the date.public static java.util.Calendar getValidCalendar(int year, int month, int day)
year
- The year part of the date.month
- The month part of the date.day
- The day part of the date.java.lang.IllegalArgumentException
- If the given date elements does not represent a valid date.public static java.util.Calendar getValidCalendar(int year, int month, int day, int hour, int minute, int second)
year
- The year part of the date.month
- The month part of the date.day
- The day part of the date.hour
- The hour part of the date.minute
- The minute part of the date.second
- The second part of the date.java.lang.IllegalArgumentException
- If the given date elements does not represent a valid date.public static void addYears(java.util.Calendar calendar, int years)
calendar
- The calendar to add the given amount of years to.years
- The amount of years to be added to the given calendar. Negative values are also
allowed, it will just go back in time.public static void addMonths(java.util.Calendar calendar, int months)
calendar
- The calendar to add the given amount of months to.months
- The amount of months to be added to the given calendar. Negative values are
also allowed, it will just go back in time.public static void addDays(java.util.Calendar calendar, int days)
calendar
- The calendar to add the given amount of days to.days
- The amount of days to be added to the given calendar. Negative values are also
allowed, it will just go back in time.public static void addHours(java.util.Calendar calendar, int hours)
calendar
- The calendar to add the given amount of hours to.hours
- The amount of hours to be added to the given calendar. Negative values are also
allowed, it will just go back in time.public static void addMinutes(java.util.Calendar calendar, int minutes)
calendar
- The calendar to add the given amount of minutes to.minutes
- The amount of minutes to be added to the given calendar. Negative values are
also allowed, it will just go back in time.public static void addSeconds(java.util.Calendar calendar, int seconds)
calendar
- The calendar to add the given amount of seconds to.seconds
- The amount of seconds to be added to the given calendar. Negative values are
also allowed, it will just go back in time.public static void addMillis(java.util.Calendar calendar, int millis)
calendar
- The calendar to add the given amount of millis to.millis
- The amount of millis to be added to the given calendar. Negative values are
also allowed, it will just go back in time.public static boolean sameYear(java.util.Calendar one, java.util.Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameMonth(java.util.Calendar one, java.util.Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameDay(java.util.Calendar one, java.util.Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameHour(java.util.Calendar one, java.util.Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameMinute(java.util.Calendar one, java.util.Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameSecond(java.util.Calendar one, java.util.Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameTime(java.util.Calendar one, java.util.Calendar two)
one
- The one calendar.two
- The other calendar.public static int elapsedYears(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedMonths(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedDays(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedHours(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedMinutes(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedSeconds(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static long elapsedMillis(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int[] elapsedTime(java.util.Calendar before, java.util.Calendar after)
before
- The first calendar with expected date before the second calendar.after
- The second calendar with expected date after the first calendar.java.lang.IllegalArgumentException
- If the first calendar is dated after the second calendar.