Class QuoteExpirationTimeUtils

java.lang.Object
de.hybris.platform.commerceservices.util.QuoteExpirationTimeUtils

public final class QuoteExpirationTimeUtils extends Object
Utility class for determining quote expiration time and checking its validity. It also provides methods for getting the configurable offer validity periods.
  • Field Details

    • DEFAULT_OFFER_VALIDITY_PERIOD_IN_DAYS

      public static final int DEFAULT_OFFER_VALIDITY_PERIOD_IN_DAYS
      See Also:
    • MIN_OFFER_VALIDITY_PERIOD_IN_DAYS

      public static final int MIN_OFFER_VALIDITY_PERIOD_IN_DAYS
      See Also:
  • Method Details

    • getDefaultOfferValidityPeriodDays

      public static int getDefaultOfferValidityPeriodDays()
      Gets the configured value for the quote default offer validity period in days or 30 if the property is not found.
      Returns:
      the quote default offer validity period in days
    • getMinOfferValidityPeriodInDays

      public static int getMinOfferValidityPeriodInDays()
      Gets the configured value for the quote minimum offer validity period in days or 1 if the property is not found.
      Returns:
      the quote minimum offer validity period in days
    • determineExpirationTime

      public static Date determineExpirationTime(Date oldExpiryDate, Date today)
      Determines the expiration time for a quote by checking if the expiration time that is currently set for the quote is valid or not using isExpirationTimeValid(Date, Date) method. If it is valid, it returns the expiration time as is, otherwise it returns an expiration time set to current date with normalized time plus the quote default offer validity period in days and with the time part set to end day.
      Parameters:
      oldExpiryDate - the expiration date that is currently set for the quote
      today - the current date with normalized time
      Returns:
      the determined expiration time for the quote
    • getEndOfDay

      public static Date getEndOfDay(Date day)
      Sets the time part of the provided input date parameter to end of day (23:59:59).
      Parameters:
      day - the date for which the time part to be set to end of day
      Returns:
      the updated date object with the time part set to end of day
    • isExpirationTimeValid

      public static boolean isExpirationTimeValid(Date expiryDate, Date today)
      Checks if the expiration date provided as input is valid or not. An expiration date is not valid if it is before the current date with normalized time plus the quote minimum offer validity period in days or it is not set. Otherwise, the expiration date is valid.
      Parameters:
      expiryDate - the expiration date to check
      today - the current date with normalized time
      Returns:
      true if the expiration date is valid, otherwise false