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 StringgetName()booleanisAfter(Instant date, String utcDate)Checks if the date is after the specified date.booleanisAfter(LocalDateTime date, String utcDate)Checks if the date is after the specified date.booleanisAfterOrEqual(Instant date, String utcDate)Checks if the date is after the specified date or is equals to it.booleanisAfterOrEqual(LocalDateTime date, String utcDate)Checks if the date is after the specified date or is equals to it.booleanisBefore(Instant date, String utcDate)Checks if the date is before the specified date.booleanisBefore(LocalDateTime date, String utcDate)Checks if the date is before the specified date.booleanisBeforeOrEqual(Instant date, String utcDate)Checks if the date is before the specified date or is equals to it.booleanisBeforeOrEqual(LocalDateTime date, String utcDate)Checks if the date is before the specified date or is equals to it.booleanisEqual(Instant date, String utcDate)Checks if dates are equal.booleanisEqual(LocalDateTime date, String utcDate)Checks if dates are equal.booleanisNotEqual(Instant date, String utcDate)Checks if dates are not equal.booleanisNotEqual(LocalDateTime date, String utcDate)Checks if dates are not equal.protected InstantparseUtcDateToInstant(String utcDate)protected LocalDateTimeparseUtcDateToLocalDateTime(String utcDate)
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getNamein 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)
-
-