Class DateFormatTransformerConfig
- All Implemented Interfaces:
Labelable
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 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:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanGets the source date formats to match.The locale used for parsing the source date.getOnSet()The property setter to use when a value is set.The locale used for formatting the target date.inthashCode()booleansetFromField(String fromField) setFromFormats(List<String> fromFormats) Sets the source date formats to match.setFromLocale(Locale fromLocale) The locale used for parsing the source date.setKeepBadDates(boolean keepBadDates) setOnSet(PropertySetter onSet) The property setter to use when a value is set.setToField(String toField) setToFormat(String toFormat) setToLocale(Locale toLocale) The locale used for formatting the target date.toString()Methods inherited from class com.norconex.importer.handler.BaseLabelableConfig
getLabel, setLabel
-
Constructor Details
-
DateFormatTransformerConfig
public DateFormatTransformerConfig()
-
-
Method Details
-
getFromFormats
Gets the source date formats to match.- Returns:
- source date formats
-
setFromFormats
Sets the source date formats to match.- Parameters:
fromFormats- source date formats
-
getFromField
-
getToField
-
getToFormat
-
getFromLocale
The locale used for parsing the source date.- Returns:
- locale
-
getToLocale
The locale used for formatting the target date.- Returns:
- locale
-
isKeepBadDates
public boolean isKeepBadDates() -
getOnSet
The property setter to use when a value is set.- Returns:
- property setter
-
setFromField
- Returns:
this.
-
setToField
- Returns:
this.
-
setToFormat
- Returns:
this.
-
setFromLocale
The locale used for parsing the source date.- Parameters:
fromLocale- locale- Returns:
this.
-
setToLocale
The locale used for formatting the target date.- Parameters:
toLocale- locale- Returns:
this.
-
setKeepBadDates
- Returns:
this.
-
setOnSet
The property setter to use when a value is set.- Parameters:
onSet- property setter- Returns:
this.
-
equals
- Overrides:
equalsin classBaseLabelableConfig
-
canEqual
- Overrides:
canEqualin classBaseLabelableConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseLabelableConfig
-
toString
- Overrides:
toStringin classBaseLabelableConfig
-