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)
-
-
Constructor Summary
Constructors Constructor Description DateExpressionVariable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getName()
boolean
isAfter(Instant date, String utcDate)
Checks if the date is after the specified date.boolean
isAfter(LocalDateTime date, String utcDate)
Checks if the date is after the specified date.boolean
isAfterOrEqual(Instant date, String utcDate)
Checks if the date is after the specified date or is equals to it.boolean
isAfterOrEqual(LocalDateTime date, String utcDate)
Checks if the date is after the specified date or is equals to it.boolean
isBefore(Instant date, String utcDate)
Checks if the date is before the specified date.boolean
isBefore(LocalDateTime date, String utcDate)
Checks if the date is before the specified date.boolean
isBeforeOrEqual(Instant date, String utcDate)
Checks if the date is before the specified date or is equals to it.boolean
isBeforeOrEqual(LocalDateTime date, String utcDate)
Checks if the date is before the specified date or is equals to it.boolean
isEqual(Instant date, String utcDate)
Checks if dates are equal.boolean
isEqual(LocalDateTime date, String utcDate)
Checks if dates are equal.boolean
isNotEqual(Instant date, String utcDate)
Checks if dates are not equal.boolean
isNotEqual(LocalDateTime date, String utcDate)
Checks if dates are not equal.protected Instant
parseUtcDateToInstant(String utcDate)
protected LocalDateTime
parseUtcDateToLocalDateTime(String utcDate)
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getName
in interfaceExpressionVariable
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- 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 comparedutcDate
- the date in UTC to compare to- Returns:
- true if date is before/equals the specified utcDate
-
parseUtcDateToLocalDateTime
protected LocalDateTime parseUtcDateToLocalDateTime(String utcDate)
-
-