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.intReturns a 1-based int value of the day of the week for the calendar, where 1 is Monday and 7 is Sunday.intdayOfWeekValue(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.intdayOfWeekValue(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.intdayOfWeekValue(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.intdayOfWeekValue(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.intnumberCalendarDates(String start, String end) Returns the number of dates in a given range.intnumberCalendarDates(String start, String end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.intnumberCalendarDates(Instant start, Instant end) Returns the number of dates in a given range.intnumberCalendarDates(Instant start, Instant end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.intnumberCalendarDates(LocalDate start, LocalDate end) Returns the number of dates in a given range.intnumberCalendarDates(LocalDate start, LocalDate end, boolean startInclusive, boolean endInclusive) Returns the number of dates in a given range.intnumberCalendarDates(ZonedDateTime start, ZonedDateTime end) Returns the number of dates in a given range.intnumberCalendarDates(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
nullif the input isnull.
-
dayOfWeek
The current day of the week for the calendar.- Parameters:
date- date- Returns:
- current day of the week, or
nullif the input isnull.
-
dayOfWeek
The current day of the week for the calendar.- Parameters:
time- time- Returns:
- current day of the week, or
nullif the input isnull.
-
dayOfWeek
The current day of the week for the calendar.- Parameters:
time- time- Returns:
- current day of the week, or
nullif 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_INTif 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_INTif 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_INTif 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_INTif 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:
daysdays afterdate, ornullif any input isnullorQueryConstants.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:
daysdays afterdate, ornullif any input isnullorQueryConstants.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:
daysdays aftertime, ornullif any input isnullorQueryConstants.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:
daysdays aftertime, ornullif any input isnullorQueryConstants.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:
daysdays beforedate, ornullif any input isnullorQueryConstants.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:
daysdays beforedate, ornullif any input isnullorQueryConstants.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:
daysdays beforetime, ornullif any input isnullorQueryConstants.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:
daysdays beforetime, ornullif any input isnullorQueryConstants.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:
daysdays after the current date, ornullifdaysisQueryConstants.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:
daysdays before the current date, ornullifdaysisQueryConstants.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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- dates between
startandend, ornullif 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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- dates between
startandend, ornullif 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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- dates between
startandend, ornullif 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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- dates between
startandend, ornullif 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
startandend, includingstartandend, ornullif 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
startandend, includingstartandend, ornullif 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
startandend, includingstartandend, ornullif 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
startandend, includingstartandend, ornullif 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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- number of dates between
startandend, orQueryConstants.NULL_INTif 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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- number of dates between
startandend, orQueryConstants.NULL_INTif 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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- number of dates between
startandend, orQueryConstants.NULL_INTif 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 includestartin the result; false to excludestartendInclusive- true to includeendin the result; false to excludeend- Returns:
- number of dates between
startandend, orQueryConstants.NULL_INTif 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
startandend, includingstartandend, orQueryConstants.NULL_INTif 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
startandend, includingstartandend, orQueryConstants.NULL_INTif 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
startandend, includingstartandend, orQueryConstants.NULL_INTif 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
startandend, includingstartandend, orQueryConstants.NULL_INTif any input isnull.
-