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 String
Gets the current date.default DayOfWeek
Gets 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.double
diffDay
(DBDateTime start, DBDateTime end) Returns the amount of time in days betweenstart
andend
.long
diffNanos
(DBDateTime start, DBDateTime end) Returns the amount of time in nanoseconds betweenstart
andend
.double
diffYear
(DBDateTime start, DBDateTime end) Returns the number of years betweenstart
andend
.name()
Gets the name of the calendar.default String
nextDay()
Gets tomorrow's date.default String
nextDay
(int days) Gets the datedays
after the current day.nextDay
(DBDateTime time) Gets the next date.nextDay
(DBDateTime time, int days) Gets the datedays
after the inputtime
.Gets the next date.Gets the datedays
after the inputdate
.int
numberOfDays
(DBDateTime start, DBDateTime end) Gets the number of days in a given range, end date exclusive.int
numberOfDays
(DBDateTime start, DBDateTime end, boolean endInclusive) Gets the number of days in a given range.int
numberOfDays
(String start, String end) Gets the number of days in a given range, end date exclusive.int
numberOfDays
(String start, String end, boolean endInclusive) Gets the number of days in a given range.default String
Gets yesterday's date.default String
previousDay
(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
days
before 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
days
beforedate
-
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
days
beforedate
-
nextDay
Gets tomorrow's date.- Returns:
- the date after the current day
-
nextDay
Gets the datedays
after 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 datedays
after 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 datedays
after 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
start
andend
-
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
start
andend
-
numberOfDays
Gets the number of days in a given range, end date exclusive.- Parameters:
start
- start of a time range; if null, returnNULL_INT
end
- end of a time range; if null, returnNULL_INT
- Returns:
- the number days between
start
andend
, inclusive and exclusive respectively.
-
numberOfDays
Gets the number of days in a given range.- Parameters:
start
- start of a time range; if null, returnNULL_INT
end
- end of a time range; if null, returnNULL_INT
endInclusive
- whether to treat theend
inclusive or exclusively- Returns:
- the number of days between
start
andend
, inclusive andendInclusive
respectively.
-
numberOfDays
Gets the number of days in a given range, end date exclusive.- Parameters:
start
- start of a time range; if null, returnNULL_INT
end
- end of a time range; if null, returnNULL_INT
- Returns:
- the number of days between
start
andend
, inclusive and exclusive respectively.
-
numberOfDays
Gets the number of days in a given range.- Parameters:
start
- start of a time range; if null, returnNULL_INT
end
- end of a time range; if null, returnNULL_INT
endInclusive
- whether to treat theend
inclusive or exclusively- Returns:
- the number of days between
start
andend
, inclusive andendInclusive
respectively.
-
diffNanos
Returns the amount of time in nanoseconds betweenstart
andend
.- 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
start
andend
-
diffDay
Returns the amount of time in days betweenstart
andend
.- 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
start
andend
-
diffYear
Returns the number of years betweenstart
andend
.- Parameters:
start
- start; if null, return nullend
- end; if null, return null- Returns:
- the amount of time in years between the
start
andend
-
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
-