Package com.illumon.util.calendar
Interface Calendar
- All Known Subinterfaces:
BusinessCalendar
- All Known Implementing Classes:
AbstractBusinessCalendar,AbstractCalendar,DefaultBusinessCalendar,DefaultNoHolidayBusinessCalendar
public interface Calendar
A calendar.
To comply with the ISO-8601 standard for Dates, Strings should
be of the form "yyyy-MM-dd",
Methods on DBDateTime may not be precisely defined enough to
return a DBDateTime, e.g nextDay(). In these cases, the method
will return a String as discussed above.
To maintain consistency, each calendar has two fields: a name,
and a time zone. A calendar with the same schedule but a
different time zone is considered a different calendar.
Frequently, the default implementation for methods on DBDateTimes is to call
the corresponding method on a String with
DBDateTime.toDateString.
This can be slower than methods written explicitly for DBDateTimes.
If performance is an issue, consider overriding these
methods with other behavior.-
Method Summary
Modifier and TypeMethodDescriptiondefault StringGets the current date.default DayOfWeekGets the day of the week for the current day.dayOfWeek(DBDateTime time) Gets the day of the week for a time.Gets the day of the week for a time.String[]daysInRange(DBDateTime start, DBDateTime end) Gets the days in a given range.String[]daysInRange(String start, String end) Gets the days in a given range.doublediffDay(DBDateTime start, DBDateTime end) Returns the amount of time in days betweenstartandend.longdiffNanos(DBDateTime start, DBDateTime end) Returns the amount of time in nanoseconds betweenstartandend.doublediffYear(DBDateTime start, DBDateTime end) Returns the number of years betweenstartandend.name()Gets the name of the calendar.default StringnextDay()Gets tomorrow's date.default StringnextDay(int days) Gets the datedaysafter the current day.nextDay(DBDateTime time) Gets the next date.nextDay(DBDateTime time, int days) Gets the datedaysafter the inputtime.Gets the next date.Gets the datedaysafter the inputdate.intnumberOfDays(DBDateTime start, DBDateTime end) Gets the number of days in a given range, end date exclusive.intnumberOfDays(DBDateTime start, DBDateTime end, boolean endInclusive) Gets the number of days in a given range.intnumberOfDays(String start, String end) Gets the number of days in a given range, end date exclusive.intnumberOfDays(String start, String end, boolean endInclusive) Gets the number of days in a given range.default StringGets yesterday's date.default StringpreviousDay(int days) Gets the date the specified number of days prior to the current day.previousDay(DBDateTime time) Gets the previous date.previousDay(DBDateTime time, int days) Gets the date the specified number of days prior to the input date.previousDay(String date) Gets the previous date.previousDay(String date, int days) Gets the date the specified number of days prior to the input date.timeZone()Gets the timezone of the calendar.
-
Method Details
-
name
String name()Gets the name of the calendar.- Returns:
- the name of the calendar
-
currentDay
Gets the current date.- Returns:
- the current day
-
previousDay
Gets yesterday's date.- Returns:
- the date before the current day
-
previousDay
Gets the date the specified number of days prior to the current day.- Parameters:
days- number of days;- Returns:
- the date
daysbefore the current day
-
previousDay
Gets the previous date.- Parameters:
time- time; if null, return null- Returns:
- the day before
time
-
previousDay
Gets the date the specified number of days prior to the input date.- Parameters:
time- time; if null, return nulldays- number of days;- Returns:
- the date
daysbeforedate
-
previousDay
Gets the previous date.- Parameters:
date- date; if null, return null- Returns:
- the date before
date
-
previousDay
Gets the date the specified number of days prior to the input date.- Parameters:
date- date; if null, return nulldays- number of days;- Returns:
- the date
daysbeforedate
-
nextDay
Gets tomorrow's date.- Returns:
- the date after the current day
-
nextDay
Gets the datedaysafter the current day.- Parameters:
days- number of days;- Returns:
- the day after the current day
-
nextDay
Gets the next date.- Parameters:
time- time; if null, return null- Returns:
- the day after
time
-
nextDay
Gets the datedaysafter the inputtime.- Parameters:
time- time; if null, return nulldays- number of days;- Returns:
- the day after
time
-
nextDay
Gets the next date.- Parameters:
date- date; if null, return null- Returns:
- the date after
time
-
nextDay
Gets the datedaysafter the inputdate.- Parameters:
date- time; if null, return nulldays- number of days;- Returns:
- the day after
time
-
daysInRange
Gets the days in a given range.- Parameters:
start- start of a time range; if null, return empty arrayend- end of a time range; if null, return empty array- Returns:
- the inclusive days between
startandend
-
daysInRange
Gets the days in a given range.- Parameters:
start- start of a time range; if null, return empty arrayend- end of a time range; if null, return empty array- Returns:
- the inclusive days between
startandend
-
numberOfDays
Gets the number of days in a given range, end date exclusive.- Parameters:
start- start of a time range; if null, returnNULL_INTend- end of a time range; if null, returnNULL_INT- Returns:
- the number days between
startandend, inclusive and exclusive respectively.
-
numberOfDays
Gets the number of days in a given range.- Parameters:
start- start of a time range; if null, returnNULL_INTend- end of a time range; if null, returnNULL_INTendInclusive- whether to treat theendinclusive or exclusively- Returns:
- the number of days between
startandend, inclusive andendInclusiverespectively.
-
numberOfDays
Gets the number of days in a given range, end date exclusive.- Parameters:
start- start of a time range; if null, returnNULL_INTend- end of a time range; if null, returnNULL_INT- Returns:
- the number of days between
startandend, inclusive and exclusive respectively.
-
numberOfDays
Gets the number of days in a given range.- Parameters:
start- start of a time range; if null, returnNULL_INTend- end of a time range; if null, returnNULL_INTendInclusive- whether to treat theendinclusive or exclusively- Returns:
- the number of days between
startandend, inclusive andendInclusiverespectively.
-
diffNanos
Returns the amount of time in nanoseconds betweenstartandend.- Parameters:
start- start time; if null, return NULL_LONGend- end time; if null, return NULL_LONG- Returns:
- the amount of time in nanoseconds between the
startandend
-
diffDay
Returns the amount of time in days betweenstartandend.- Parameters:
start- start time; if null, return NULL_LONGend- end time; if null, return NULL_LONG- Returns:
- the amount of time in days between the
startandend
-
diffYear
Returns the number of years betweenstartandend.- Parameters:
start- start; if null, return nullend- end; if null, return null- Returns:
- the amount of time in years between the
startandend
-
dayOfWeek
Gets the day of the week for the current day.- Returns:
- the day of the week of the current day
-
dayOfWeek
Gets the day of the week for a time.- Parameters:
time- time; if null, return null- Returns:
- the day of the week of
time
-
dayOfWeek
Gets the day of the week for a time.- Parameters:
date- date; if null, return null- Returns:
- the day of the week of
date
-
timeZone
DBTimeZone timeZone()Gets the timezone of the calendar.- Returns:
- the time zone of the calendar
-