Class DateFormatTransformer
- All Implemented Interfaces:
Configurable<DateFormatTransformerConfig>,ConfigurableDocHandler<DateFormatTransformerConfig>,DocHandler
Formats a date from any given format to a format of choice, as per the
formatting options found on ZonedDateTimeParser with the addition
of the format "EPOCH", which represents the difference, measured in
milliseconds, between the date and midnight, January 1, 1970.
The default format
for fromFormat or toFormat when not specified
is EPOCH.
When omitting the toField, the value will replace the one
in the same field.
Storing values in an existing field
If a target field with the same name already exists for a document,
values will be added to the end of the existing value list.
It is possible to change this default behavior
with DateFormatTransformerConfig.setOnSet(PropertySetter).
Can be used both as a pre-parse or post-parse handler.
It is possible to specify a locale used for parsing and formatting dates. The locale is the ISO two-letter language code, with an optional ISO country code, separated with an underscore (e.g., "fr" for French, "fr_CA" for Canadian French). When no locale is specified, the default is English.
Multiple fromFormat values can be specified. Each formats will
be tried in the order provided and the first format that succeed in
parsing a date will be used.
A date will be considered "bad" only if none of the formats could parse the
date.
The following converts a date that is sometimes obtained from the HTTP header "Last-Modified" and sometimes is an EPOCH date, into an Apache Solr date format:
- See Also:
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTYFields inherited from interface com.norconex.importer.handler.DocHandler
NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanbooleanhandle(DocHandlerContext docCtx) Perform any operations on a document.inthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.norconex.importer.handler.DocHandler
close, init
-
Constructor Details
-
DateFormatTransformer
public DateFormatTransformer()
-
-
Method Details
-
handle
Description copied from interface:DocHandlerPerform any operations on a document.- Specified by:
handlein interfaceDocHandler- Parameters:
docCtx- the document handling context- Returns:
falseto stop processing and reject a document ortrueto proceed to the next configured handler.- Throws:
IOException- An I/O exception of some sort has occurred
-
getConfiguration
- Specified by:
getConfigurationin interfaceConfigurable<DateFormatTransformerConfig>
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-