Interface BusinessCalendar

All Known Implementing Classes:
BusinessCalendarImpl

public interface BusinessCalendar
Defines API to operate with date and time in terms of "business hours".
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a date-time of the next end of business interval relative to provided date-time: If initial date-time is within interval - returns end-time of this interval If initial date-time is outside of interval or points exact at its end-time - returns end-time of next interval
    Returns a date-time of the previous end of business interval relative to provided date-time: Always returns end-time of previous interval.
    Returns a date-time of the next start of business interval relative to provided date-time: Always returns start-time of next interval.
    Returns a date-time of the previous start of business interval relative to provided date-time: If initial date-time is within interval - returns start-time of this interval If initial date-time is outside of interval or points exact at its start-time - returns start-time of previous interval
    Returns code of given business calendar which should be unique among all registered calendars.
    Returns human-readable name of given business calendar.
    Returns source from which given calendar come from.
    boolean
    Checks if provided date belongs to business days.
    boolean
    Checks if provided date-time belongs to business time.
    minus(LocalDate date, int daysToSubtract)
    Returns a copy of provided date with the specified amount of business days subtracted.
    minus(LocalDateTime dateTime, int hoursToSubtract)
    Returns a copy of provided date-time with the specified amount of business hours subtracted.
    minus(LocalDateTime dateTime, Duration duration)
    Returns a copy of provided date-time with the specified duration in terms of working time subtracted.
    plus(LocalDate date, int daysToAdd)
    Returns a copy of provided date with the specified amount of business days added.
    plus(LocalDateTime dateTime, int hoursToAdd)
    Returns a copy of provided date-time with the specified amount of business hours added.
    plus(LocalDateTime dateTime, Duration duration)
    Returns a copy of provided date-time with the specified duration in terms of working time added.
  • Method Details

    • getName

      String getName()
      Returns human-readable name of given business calendar.
      Returns:
      calendar's name
    • getCode

      String getCode()
      Returns code of given business calendar which should be unique among all registered calendars.
      Returns:
      calendar's unique identifier
    • getSource

      String getSource()
      Returns source from which given calendar come from. Possible variants are annotatedClass and database.
      Returns:
      calendar's source
      See Also:
    • isBusinessDay

      boolean isBusinessDay(LocalDate date)
      Checks if provided date belongs to business days.
      Parameters:
      date - date to be checked.
      Returns:
      true if this date is business day.
    • plus

      LocalDate plus(LocalDate date, int daysToAdd)
      Returns a copy of provided date with the specified amount of business days added.
      Parameters:
      date - source date.
      daysToAdd - count of business days to add.
      Returns:
      a LocalDate based on provided with the specified amount of provided business days added.
    • minus

      LocalDate minus(LocalDate date, int daysToSubtract)
      Returns a copy of provided date with the specified amount of business days subtracted.
      Parameters:
      date - source date.
      daysToSubtract - count of business days to subtract.
      Returns:
      a LocalDate based on provided with the specified amount of provided business days subtracted.
    • isBusinessTime

      boolean isBusinessTime(LocalDateTime dateTime)
      Checks if provided date-time belongs to business time.
      Parameters:
      dateTime - source date-time.
      Returns:
      true if provided date-time is business time.
    • plus

      LocalDateTime plus(LocalDateTime dateTime, int hoursToAdd)
      Returns a copy of provided date-time with the specified amount of business hours added.
      Parameters:
      dateTime - source date-time.
      hoursToAdd - count of working hours to added.
      Returns:
      a LocalDateTime based on provided date-time with the addition of provided working hours made.
    • minus

      LocalDateTime minus(LocalDateTime dateTime, int hoursToSubtract)
      Returns a copy of provided date-time with the specified amount of business hours subtracted.
      Parameters:
      dateTime - source date-time.
      hoursToSubtract - count of working hours to subtract.
      Returns:
      a LocalDateTime based on provided date-time with the extraction of provided working hours made.
    • plus

      LocalDateTime plus(LocalDateTime dateTime, Duration duration)
      Returns a copy of provided date-time with the specified duration in terms of working time added.

      Extra caution is needed when duration is obtained using the number of days. In this case the resulting date-time will be calculated by adding 24*days business hours that might be not desired behavior.

      Parameters:
      dateTime - source date-time.
      duration - duration in terms of working time to be added.
      Returns:
      a LocalDateTime based on provided date-time with the addition of provided duration made.
    • minus

      LocalDateTime minus(LocalDateTime dateTime, Duration duration)
      Returns a copy of provided date-time with the specified duration in terms of working time subtracted.

      Extra caution is needed when duration is obtained using the number of days. In this case the resulting date-time will be calculated by subtracting 24*days business hours that might be not desired behavior.

      Parameters:
      dateTime - source date-time.
      duration - duration in terms of working time to be subtracted.
      Returns:
      a LocalDateTime based on provided date-time with the extraction of provided duration made.
    • getBusinessIntervalStartAfter

      LocalDateTime getBusinessIntervalStartAfter(LocalDateTime dateTime)
      Returns a date-time of the next start of business interval relative to provided date-time: Always returns start-time of next interval.
      Parameters:
      dateTime - initial date-time.
      Returns:
      LocalDateTime with start-time of next interval.
    • getBusinessIntervalStartBefore

      LocalDateTime getBusinessIntervalStartBefore(LocalDateTime dateTime)
      Returns a date-time of the previous start of business interval relative to provided date-time:
      • If initial date-time is within interval - returns start-time of this interval
      • If initial date-time is outside of interval or points exact at its start-time - returns start-time of previous interval
      Parameters:
      dateTime - initial date-time.
      Returns:
      LocalDateTime with previous start-time.
    • getBusinessIntervalEndAfter

      LocalDateTime getBusinessIntervalEndAfter(LocalDateTime dateTime)
      Returns a date-time of the next end of business interval relative to provided date-time:
      • If initial date-time is within interval - returns end-time of this interval
      • If initial date-time is outside of interval or points exact at its end-time - returns end-time of next interval
      Parameters:
      dateTime - initial date-time.
      Returns:
      LocalDateTime with next end-time.
    • getBusinessIntervalEndBefore

      LocalDateTime getBusinessIntervalEndBefore(LocalDateTime dateTime)
      Returns a date-time of the previous end of business interval relative to provided date-time: Always returns end-time of previous interval.
      Parameters:
      dateTime - initial date-time.
      Returns:
      LocalDateTime with end-time of previous interval.