Class DateCondition
- All Implemented Interfaces:
Configurable<DateConditionConfig>,Condition,ConfigurableCondition<DateConditionConfig>,FailablePredicate<DocHandlerContext,IOException>
A condition based on the date value(s) of matching
metadata fields given the supplied date format. If multiple values are
found for a field, only one of them needs to match for this condition to
be true.
If the value is not a valid date, it is considered not to be matching
(i.e., false).
The default operator is "eq" (equals).
Single date vs range of dates:
This condition accepts zero, one, or two value matchers:
- 0: Use no value matcher to simply evaluate whether the value is a date.
- 1: Use one value matcher to evaluate if the value is lower/greater and/or the same as the specified date.
-
2: Use two value matchers to define a date range to evaluate
(both matches have to evaluate to
true).
Metadata date field format:
To successfully parse a date, you can specify a date format,
as per the formatting options found on DateTimeFormatter.
The default format when not specified is EPOCH (the difference, measured in
milliseconds, between the date and midnight, January 1, 1970).
Absolute date conditions:
When defining a date value matcher, you can specify an absolute date (i.e. a constant date value) to be used for comparison. Supported formats for configuring an absolute date are:
yyyy-MM-dd -> date (e.g. 2015-05-31)
yyyy-MM-ddThh:mm:ss[.SSS] -> date and time with optional
milliseconds (e.g. 2015-05-31T22:44:15)
Relative date conditions:
Date value matchers can also specify a moment in time relative to the
current date using the TODAY or NOW keyword,
optionally followed by a number of time units to add/remove.
TODAY is the current day without the hours, minutes, and
seconds, where as NOW is the current day with the hours,
minutes, and seconds. You can also decide whether you want the
current date to be fixed for the lifetime of this condition (does not change
after being set for the first time), or whether
it should be refreshed on every invocation to reflect the passing of time.
Time zones:
When comparing dates at a more granular level (e.g., hours, minutes, seconds), it may be important to take time zones into account. If the time zone (id or offset) is part of a document field date value and this filter configured format supports time zones, it will respect the time zone in the encountered time zone.
In cases where you want to specify the time zone for values
without one, you can do so with
the DateConditionConfig.setDocZoneId(ZoneId) method.
Explicitly setting a document time zone that way has no effect
if the date already defines its own zone.
The default time zone when none is specified is UTC.
When using XML configuration to define the condition dates, you can
specify the time zone using the conditionZoneId option.
Operator- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enum -
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTYFields inherited from interface org.apache.commons.lang3.function.FailablePredicate
FALSE, TRUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleaninthashCode()booleantest(DocHandlerContext docCtx) toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.lang3.function.FailablePredicate
and, negate, or
-
Constructor Details
-
DateCondition
public DateCondition()
-
-
Method Details
-
test
- Specified by:
testin interfaceFailablePredicate<DocHandlerContext,IOException> - Throws:
IOException
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-
getConfiguration
- Specified by:
getConfigurationin interfaceConfigurable<DateConditionConfig>
-