public final class CalendarUtil
extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addDays(Calendar calendar,
int days)
Add the given amount of days to the given calendar.
|
static void |
addHours(Calendar calendar,
int hours)
Add the given amount of hours to the given calendar.
|
static void |
addMillis(Calendar calendar,
int millis)
Add the given amount of millis to the given calendar.
|
static void |
addMinutes(Calendar calendar,
int minutes)
Add the given amount of minutes to the given calendar.
|
static void |
addMonths(Calendar calendar,
int months)
Add the given amount of months to the given calendar.
|
static void |
addSeconds(Calendar calendar,
int seconds)
Add the given amount of seconds to the given calendar.
|
static void |
addYears(Calendar calendar,
int years)
Add the given amount of years to the given calendar.
|
static int |
elapsedDays(Calendar before,
Calendar after)
Retrieve the amount of elapsed days between the two given calendars.
|
static int |
elapsedHours(Calendar before,
Calendar after)
Retrieve the amount of elapsed hours between the two given calendars.
|
static long |
elapsedMillis(Calendar before,
Calendar after)
Retrieve the amount of elapsed milliseconds between the two given
calendars.
|
static int |
elapsedMinutes(Calendar before,
Calendar after)
Retrieve the amount of elapsed minutes between the two given calendars.
|
static int |
elapsedMonths(Calendar before,
Calendar after)
Retrieve the amount of elapsed months between the two given calendars.
|
static int |
elapsedSeconds(Calendar before,
Calendar after)
Retrieve the amount of elapsed seconds between the two given calendars.
|
static int[] |
elapsedTime(Calendar before,
Calendar after)
Calculate the total of elapsed time from years up to seconds between the
two given calendars.
|
static int |
elapsedYears(Calendar before,
Calendar after)
Retrieve the amount of elapsed years between the two given calendars.
|
static 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 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(Calendar one,
Calendar two)
Returns true if the two given calendars are dated on the same
year, month and day.
|
static boolean |
sameHour(Calendar one,
Calendar two)
Returns true if the two given calendars are dated on the same
year, month, day and hour.
|
static boolean |
sameMinute(Calendar one,
Calendar two)
Returns true if the two given calendars are dated on the same
year, month, day, hour and minute.
|
static boolean |
sameMonth(Calendar one,
Calendar two)
Returns true if the two given calendars are dated on the same
year and month.
|
static boolean |
sameSecond(Calendar one,
Calendar two)
Returns true if the two given calendars are dated on the same
year, month, day, hour, minute and second.
|
static boolean |
sameTime(Calendar one,
Calendar two)
Returns true if the two given calendars are dated on the same
time.
|
static boolean |
sameYear(Calendar one,
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 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.IllegalArgumentException
- If the given date elements does not represent a valid date.public static 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.IllegalArgumentException
- If the given date elements does not represent a valid date.public static void addYears(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(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(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(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(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(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(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(Calendar one, Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameMonth(Calendar one, Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameDay(Calendar one, Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameHour(Calendar one, Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameMinute(Calendar one, Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameSecond(Calendar one, Calendar two)
one
- The one calendar.two
- The other calendar.public static boolean sameTime(Calendar one, Calendar two)
one
- The one calendar.two
- The other calendar.public static int elapsedYears(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedMonths(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedDays(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedHours(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedMinutes(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int elapsedSeconds(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static long elapsedMillis(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.public static int[] elapsedTime(Calendar before, Calendar after)
before
- The first calendar with expected date before the second
calendar.after
- The second calendar with expected date after the first
calendar.IllegalArgumentException
- If the first calendar is dated after the second calendar.Copyright © 2010-2020 Toolsverse. All Rights Reserved.