Interface TimeRange

  • All Known Implementing Classes:
    DayRange, MonthRange, QuarterRange, WeekRange, YearRange

    public interface TimeRange

    The Interface provides Strategy methods (http://en.wikipedia.org/wiki/Strategy_pattern) to calculate border dates for time ranges. Any new Strategy have to be implemented using this interface. By default there are five Strategies provided by B2B extension:

    Adding new Strategy is a four steps process.

    • creating class implementing this interface
    • adding Spring configuration entry in resources/b2bcore-spring.xml like this:
         <bean id="de.hybris.platform.b2b.scope.YourRange" name="YOUR_RANGE" class="de.hybris.platform.b2b.scope.YourRange" scope="singleton" />
       
    • adding new value to Hybris Enumeration type called B2BPeriodRange in resources/b2bcore-items.xml like this:
         <value code="YOUR_RANGE" />
       
    • adding localized name of new Enumeration value in appropriate files stored in resources/localization/ directory to "Time ranges" section:
        type.b2bperiodrange.your_range.name=Your range
       

    The last step is very important, so please be careful and add it immediately after creating new Enumeration value. Localized names have to be provided for all supported languages in your application.

    • Method Detail

      • getEndOfRange

        java.util.Calendar getEndOfRange​(java.util.Calendar calendar)
        Gets the end of range. It is assumed that hour, minute and second in return Calendar object is set to 23:59:59.
        Parameters:
        calendar - object to determines current date/time, which is base date/time for calculations
        Returns:
        the end of range
      • getStartOfRange

        java.util.Calendar getStartOfRange​(java.util.Calendar calendar)
        Gets the start of range. It is assumed that hour, minute and second in return Calendar object is set to 00:00:00.
        Parameters:
        calendar - object to determines current date and time, which is base date/time for calculations
        Returns:
        the start of range