Skip to main content

CurrentDateTransformer

Adds the current computer UTC date to the specified field

Notesโ€‹

This functionality allows you to adds the current computer UTC date to the specified field. If no field is provided, the date will be added to document.importedDate.

The default date format is EPOCH (the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC). A custom date format can be specified with the format attribute, as per the formatting options found on SimpleDateFormat.

It is possible to specify a locale used for 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 "en_US" (US English).

Storing values in an existing fieldโ€‹

If a document already has a target field with the same name, new values are appended to the existing list by default. Use onSet to manage this default behavior.

Parser Handler Compatibilityโ€‹

This functionality can be applied as either a pre-parse or post-parse handler.

Locale of Date Formattingโ€‹

It is possible to specify a locale used for 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 en_US (US English).

Examplesโ€‹

The following example store the current date along with hours and minutes in a "crawl_date" field.

handler:
class: CurrentDateTransformer
format: yyyy-MM-dd HH:mm
toField: crawl_date

Usageโ€‹

Full configuration skeleton, with every option and its default
class: CurrentDateTransformer
format: string
label: string
locale: string
onSet: APPEND
toField: string

Propertiesโ€‹

PropertyTypeRequiredDefault
formatstringNo-
labelstringNo-
localestringNo-
onSetenumNo-
toFieldstringNodocument.importedDate

Property Detailsโ€‹

formatโ€‹

Specifies the format of the date to be added.

labelโ€‹

An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing โ€” it exists purely to help identify this step, for example in large configurations or in the visual configurator.

localeโ€‹

Specifies the locale used for formatting

onSetโ€‹

What to do if a target field of the same name already exist.

Allowed Valuesโ€‹

  • APPEND
  • PREPEND
  • REPLACE
  • OPTIONAL

toFieldโ€‹

A target field name used to store the value.