Class Calendar
- Direct Known Subclasses:
BusinessCalendar
A calendar is associated with a specific time zone.
Date strings must be in a format that can be parsed by DateTimeUtils.parseLocalDate(String)
. Methods that
accept strings can be slower than methods written explicitly for Instant
, ZonedDateTime
, or
LocalDate
.
-
Method Summary
Modifier and TypeMethodDescriptionThe current date for the calendar.String[]
calendarDates
(String start, String end) Returns the dates in a given range.String[]
calendarDates
(String start, String end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.calendarDates
(Instant start, Instant end) Returns the dates in a given range.calendarDates
(Instant start, Instant end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.calendarDates
(LocalDate start, LocalDate end) Returns the dates in a given range.calendarDates
(LocalDate start, LocalDate end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.calendarDates
(ZonedDateTime start, ZonedDateTime end) Returns the dates in a given range.calendarDates
(ZonedDateTime start, ZonedDateTime end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.The current day of the week for the calendar.The current day of the week for the calendar.The current day of the week for the calendar.The current day of the week for the calendar.dayOfWeek
(ZonedDateTime time) The current day of the week for the calendar.int
Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.int
dayOfWeekValue
(String date) Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.int
dayOfWeekValue
(Instant time) Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.int
dayOfWeekValue
(LocalDate date) Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.int
dayOfWeekValue
(ZonedDateTime time) Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.Gets the description of the calendar.futureDate
(int days) Adds a specified number of days to the current date.Subtracts a specified number of days to an input date.Subtracts a specified number of days to an input time.Subtracts a specified number of days to an input date.minusDays
(ZonedDateTime time, int days) Subtracts a specified number of days to an input time.name()
Gets the name of the calendar.int
numberCalendarDates
(String start, String end) Returns the number of dates in a given range.int
numberCalendarDates
(String start, String end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.int
numberCalendarDates
(Instant start, Instant end) Returns the number of dates in a given range.int
numberCalendarDates
(Instant start, Instant end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.int
numberCalendarDates
(LocalDate start, LocalDate end) Returns the number of dates in a given range.int
numberCalendarDates
(LocalDate start, LocalDate end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.int
numberCalendarDates
(ZonedDateTime start, ZonedDateTime end) Returns the number of dates in a given range.int
numberCalendarDates
(ZonedDateTime start, ZonedDateTime end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.pastDate
(int days) Subtracts a specified number of days from the current date.Adds a specified number of days to an input date.Adds a specified number of days to an input time.Adds a specified number of days to an input date.plusDays
(ZonedDateTime time, int days) Adds a specified number of days to an input time.timeZone()
Gets the timezone of the calendar.toString()
-
Method Details
-
name
Gets the name of the calendar.- Returns:
- the name of the calendar
-
description
Gets the description of the calendar.- Returns:
- the description of the calendar
-
timeZone
Gets the timezone of the calendar.- Returns:
- the time zone of the calendar
-
toString
-
calendarDate
The current date for the calendar.- Returns:
- current date
-
dayOfWeek
The current day of the week for the calendar.- Returns:
- current day of the week
-
dayOfWeek
The current day of the week for the calendar.- Parameters:
date
- date- Returns:
- current day of the week, or
null
if the input isnull
.
-
dayOfWeek
The current day of the week for the calendar.- Parameters:
date
- date- Returns:
- current day of the week, or
null
if the input isnull
.
-
dayOfWeek
The current day of the week for the calendar.- Parameters:
time
- time- Returns:
- current day of the week, or
null
if the input isnull
.
-
dayOfWeek
The current day of the week for the calendar.- Parameters:
time
- time- Returns:
- current day of the week, or
null
if the input isnull
.
-
dayOfWeekValue
public int dayOfWeekValue()Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.- Returns:
- current day of the week
-
dayOfWeekValue
Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.- Parameters:
date
- date- Returns:
- current day of the week, or
QueryConstants.NULL_INT
if the input isnull
.
-
dayOfWeekValue
Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.- Parameters:
date
- date- Returns:
- current day of the week, or
QueryConstants.NULL_INT
if the input isnull
.
-
dayOfWeekValue
Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.- Parameters:
time
- time- Returns:
- current day of the week, or
QueryConstants.NULL_INT
if the input isnull
.
-
dayOfWeekValue
Returns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.- Parameters:
time
- time- Returns:
- current day of the week, or
QueryConstants.NULL_INT
if the input isnull
.
-
plusDays
Adds a specified number of days to an input date. Adding negative days is equivalent to subtracting days.- Parameters:
date
- datedays
- number of days to add- Returns:
days
days afterdate
, ornull
if any input isnull
orQueryConstants.NULL_INT
.
-
plusDays
Adds a specified number of days to an input date. Adding negative days is equivalent to subtracting days.- Parameters:
date
- datedays
- number of days to add- Returns:
days
days afterdate
, ornull
if any input isnull
orQueryConstants.NULL_INT
.- Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
plusDays
Adds a specified number of days to an input time. Adding negative days is equivalent to subtracting days.Day additions are not always 24 hours. The resultant time will have the same local time as the input time, as determined by the calendar's time zone. This accounts for Daylight Savings Time. For example, 2023-11-05 has a daylight savings time adjustment, so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference.
- Parameters:
time
- timedays
- number of days to add- Returns:
days
days aftertime
, ornull
if any input isnull
orQueryConstants.NULL_INT
.
-
plusDays
Adds a specified number of days to an input time. Adding negative days is equivalent to subtracting days.Day additions are not always 24 hours. The resultant time will have the same local time as the input time, as determined by the calendar's time zone. This accounts for Daylight Savings Time. For example, 2023-11-05 has a daylight savings time adjustment, so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference.
The resultant time will have the same time zone as the calendar. This could be different than the time zone of the input
ZonedDateTime
.- Parameters:
time
- timedays
- number of days to add- Returns:
days
days aftertime
, ornull
if any input isnull
orQueryConstants.NULL_INT
.
-
minusDays
Subtracts a specified number of days to an input date. Subtracting negative days is equivalent to adding days.- Parameters:
date
- datedays
- number of days to subtract- Returns:
days
days beforedate
, ornull
if any input isnull
orQueryConstants.NULL_INT
.
-
minusDays
Subtracts a specified number of days to an input date. Subtracting negative days is equivalent to adding days.- Parameters:
date
- datedays
- number of days to subtract- Returns:
days
days beforedate
, ornull
if any input isnull
orQueryConstants.NULL_INT
.- Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
minusDays
Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days.Day subtractions are not always 24 hours. The resultant time will have the same local time as the input time, as determined by the calendar's time zone. This accounts for Daylight Savings Time. For example, 2023-11-05 has a daylight savings time adjustment, so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference.
- Parameters:
time
- timedays
- number of days to subtract- Returns:
days
days beforetime
, ornull
if any input isnull
orQueryConstants.NULL_INT
.
-
minusDays
Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days.Day subtractions are not always 24 hours. The resultant time will have the same local time as the input time, as determined by the calendar's time zone. This accounts for Daylight Savings Time. For example, 2023-11-05 has a daylight savings time adjustment, so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference.
The resultant time will have the same time zone as the calendar. This could be different than the time zone of the input
ZonedDateTime
.- Parameters:
time
- timedays
- number of days to subtract- Returns:
days
days beforetime
, ornull
if any input isnull
orQueryConstants.NULL_INT
.
-
futureDate
Adds a specified number of days to the current date. Adding negative days is equivalent to subtracting days.- Parameters:
days
- number of days to add.- Returns:
days
days after the current date, ornull
ifdays
isQueryConstants.NULL_INT
.
-
pastDate
Subtracts a specified number of days from the current date. Subtracting negative days is equivalent to adding days.- Parameters:
days
- number of days to subtract.- Returns:
days
days before the current date, ornull
ifdays
isQueryConstants.NULL_INT
.
-
calendarDates
public LocalDate[] calendarDates(LocalDate start, LocalDate end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- dates between
start
andend
, ornull
if any input isnull
.
-
calendarDates
public String[] calendarDates(String start, String end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- dates between
start
andend
, ornull
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
calendarDates
public LocalDate[] calendarDates(ZonedDateTime start, ZonedDateTime end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- dates between
start
andend
, ornull
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
calendarDates
public LocalDate[] calendarDates(Instant start, Instant end, boolean startInclusive, boolean endInclusive) Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- dates between
start
andend
, ornull
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
calendarDates
Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- dates between
start
andend
, includingstart
andend
, ornull
if any input isnull
.
-
calendarDates
Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- dates between
start
andend
, includingstart
andend
, ornull
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
calendarDates
Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- dates between
start
andend
, includingstart
andend
, ornull
if any input isnull
.
-
calendarDates
Returns the dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- dates between
start
andend
, includingstart
andend
, ornull
if any input isnull
.
-
numberCalendarDates
public int numberCalendarDates(LocalDate start, LocalDate end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- number of dates between
start
andend
, orQueryConstants.NULL_INT
if any input isnull
.
-
numberCalendarDates
public int numberCalendarDates(String start, String end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- number of dates between
start
andend
, orQueryConstants.NULL_INT
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
numberCalendarDates
public int numberCalendarDates(ZonedDateTime start, ZonedDateTime end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- number of dates between
start
andend
, orQueryConstants.NULL_INT
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
numberCalendarDates
public int numberCalendarDates(Instant start, Instant end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time rangestartInclusive
- true to includestart
in the result; false to excludestart
endInclusive
- true to includeend
in the result; false to excludeend
- Returns:
- number of dates between
start
andend
, orQueryConstants.NULL_INT
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
numberCalendarDates
Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- number of dates between
start
andend
, includingstart
andend
, orQueryConstants.NULL_INT
if any input isnull
.
-
numberCalendarDates
Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- number of dates between
start
andend
, includingstart
andend
, orQueryConstants.NULL_INT
if any input isnull
. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
numberCalendarDates
Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- number of dates between
start
andend
, includingstart
andend
, orQueryConstants.NULL_INT
if any input isnull
.
-
numberCalendarDates
Returns the number of dates in a given range.- Parameters:
start
- start of a time rangeend
- end of a time range- Returns:
- number of dates between
start
andend
, includingstart
andend
, orQueryConstants.NULL_INT
if any input isnull
.
-