Class DateConditionConfig

All Implemented Interfaces:
Labelable

public class DateConditionConfig extends BaseConditionConfig

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 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:
  • Constructor Details

    • DateConditionConfig

      public DateConditionConfig()
  • Method Details

    • setFieldMatcher

      public DateConditionConfig setFieldMatcher(TextMatcher fieldMatcher)
      Sets the text matcher of field names. Copies it.
      Parameters:
      fieldMatcher - text matcher
    • setConditionZoneId

      public DateConditionConfig setConditionZoneId(ZoneId conditionZoneId)
    • setValueMatcher

      public DateConditionConfig setValueMatcher(DateValueMatcher valueMatcher)
    • setValueMatcherRangeEnd

      public DateConditionConfig setValueMatcherRangeEnd(DateValueMatcher valueMatcherRangeEnd)
    • getFieldMatcher

      public TextMatcher getFieldMatcher()
      Field name(s) text matcher.
      Returns:
      field matcher
    • getValueMatcher

      public DateValueMatcher getValueMatcher()
      Value matcher for a date, or the begining of a date range (if an end date value matcher is also supplied).
      Returns:
      date matcher
    • getValueMatcherRangeEnd

      public DateValueMatcher getValueMatcherRangeEnd()
      Value matcher for then end of a date range. Only set when dealing with date ranges.
      Returns:
      end of range date matcher
    • getFormat

      public String getFormat()
      The format of a document date field value (see class documentation).
      Returns:
      date format
    • getDocZoneId

      public ZoneId getDocZoneId()
      Time zone id to use for dates associated with a document when evaluating date conditions.
      Returns:
      document zone id
    • getConditionZoneId

      public ZoneId getConditionZoneId()
      Default time zone id applied to condition dates that do not specify their own (i.e., value matchers without an explicit zoneId and whose date string carries no zone). A zone set directly on a value matcher takes precedence. When neither is set, condition dates default to UTC.
      Returns:
      condition zone id
    • setFormat

      public DateConditionConfig setFormat(String format)
      The format of a document date field value (see class documentation).
      Parameters:
      format - date format
      Returns:
      this.
    • setDocZoneId

      public DateConditionConfig setDocZoneId(ZoneId docZoneId)
      Time zone id to use for dates associated with a document when evaluating date conditions.
      Parameters:
      docZoneId - document zone id
      Returns:
      this.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class BaseLabelableConfig
    • canEqual

      protected boolean canEqual(Object other)
      Overrides:
      canEqual in class BaseLabelableConfig
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BaseLabelableConfig
    • toString

      public String toString()
      Overrides:
      toString in class BaseLabelableConfig