Class DateExpressionVariable

java.lang.Object
com.broadleafcommerce.rulesengine.expression.util.DateExpressionVariable
All Implemented Interfaces:
ExpressionVariable

public class DateExpressionVariable extends Object implements ExpressionVariable

Common operations for dates comparison

The methods in this class expect the compared date to be in UTC.

An instance of this class will usually be accessible as a variable within an expression via #dates.

Author:
Dima Myroniuk (dmyroniuk)
  • Field Details

  • Constructor Details

    • DateExpressionVariable

      public DateExpressionVariable()
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface ExpressionVariable
      Returns:
      Name of the variable, must not be null
    • isEqual

      public final boolean isEqual(@Nullable Instant date, String utcDate)
      Checks if dates are equal.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is equal to the specified utcDate
    • isEqual

      public final boolean isEqual(@Nullable LocalDateTime date, String utcDate)
      Checks if dates are equal.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is equal to the specified utcDate
    • isNotEqual

      public final boolean isNotEqual(@Nullable Instant date, String utcDate)
      Checks if dates are not equal.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is not equal to the specified utcDate
    • isNotEqual

      public final boolean isNotEqual(@Nullable LocalDateTime date, String utcDate)
      Checks if dates are not equal.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is not equal to the specified utcDate
    • isAfter

      public final boolean isAfter(@Nullable Instant date, String utcDate)
      Checks if the date is after the specified date.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is after the specified utcDate
    • isAfter

      public final boolean isAfter(@Nullable LocalDateTime date, String utcDate)
      Checks if the date is after the specified date.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is after the specified utcDate
    • isAfterOrEqual

      public final boolean isAfterOrEqual(@Nullable Instant date, String utcDate)
      Checks if the date is after the specified date or is equals to it.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is after/equals the specified utcDate
    • isAfterOrEqual

      public final boolean isAfterOrEqual(@Nullable LocalDateTime date, String utcDate)
      Checks if the date is after the specified date or is equals to it.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is after/equals the specified utcDate
    • isBefore

      public final boolean isBefore(@Nullable Instant date, String utcDate)
      Checks if the date is before the specified date.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is before the specified utcDate
    • isBefore

      public final boolean isBefore(@Nullable LocalDateTime date, String utcDate)
      Checks if the date is before the specified date.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is before the specified utcDate
    • isBeforeOrEqual

      public final boolean isBeforeOrEqual(@Nullable Instant date, String utcDate)
      Checks if the date is before the specified date or is equals to it.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is before/equals the specified utcDate
    • isBeforeOrEqual

      public final boolean isBeforeOrEqual(@Nullable LocalDateTime date, String utcDate)
      Checks if the date is before the specified date or is equals to it.
      Parameters:
      date - the date to be compared
      utcDate - the date in UTC to compare to
      Returns:
      true if date is before/equals the specified utcDate
    • parseUtcDateToInstant

      protected Instant parseUtcDateToInstant(String utcDate)
    • parseUtcDateToLocalDateTime

      protected LocalDateTime parseUtcDateToLocalDateTime(String utcDate)