Package io.deephaven.time.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 Instant may not be precisely defined enough to return an Instant, 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 Instants is to call the corresponding method on a String with
DateTimeUtils.formatDate. This can be slower than methods written explicitly for DateTimes. 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.Gets the day of the week for a time.Gets the day of the week for a time.String[]daysInRange(String start, String end) Gets the days in a given range.String[]daysInRange(Instant start, Instant end) Gets the days in a given range.doubleReturns the amount of time in days betweenstartandend.longReturns the amount of time in nanoseconds betweenstartandend.doublediffYear365(Instant start, Instant end) Returns the number of 365 day years betweenstartandend.doublediffYearAvg(Instant start, Instant end) Returns the number of average (365.2425 day) 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.Gets the next date.Gets the datedaysafter the inputdate.Gets the next date.Gets the datedaysafter the inputtime.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.intnumberOfDays(Instant start, Instant end) Gets the number of days in a given range, end date exclusive.intnumberOfDays(Instant start, Instant 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(String date) Gets the previous date.previousDay(String date, int days) Gets the date the specified number of days prior to the input date.previousDay(Instant time) Gets the previous date.previousDay(Instant time, 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
-
diffYear365
Returns the number of 365 day years betweenstartandend.- Parameters:
start- start; if null, return nullend- end; if null, return null- Returns:
- the amount of time in years between the
startandend
-
diffYearAvg
Returns the number of average (365.2425 day) 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
ZoneId timeZone()Gets the timezone of the calendar.- Returns:
- the time zone of the calendar
-