date format transformer

Date Format Transformer

Version: 17.07

Supported Since: 17.07

What is a Date Format Transformer?

Date Format Extractor processing element can be used to transform a given input date string into to a preferred standard date format. The input can be set as a message context scope variable, message property, message transport header or users can directly provide the relevant date string as a property to the processing element configuration. If you are using a scope variable or a message property to provide the input date it can be a java.util.Date type or java.lang.String type. In the processing element configuration you can define the format to be transformed for the provided date. Also you can define where the resultant transformed date should be assigned to, ie: to a scope variable, message property or a message header, and the name of the parameter which will hold the result.

Out Ports

date transform outports

Next

The processing element will transform given date into a relevant new format and then assign it to a variable/property/header and then it will be forwarded to this out port

On Exception

The message will be sent to this outport if any exception occurred while transforming the date into the requested format

Parameters

Input Type

Using this property you need to define how will you provide the date. From the dropdown menu you will be able to select on of the following options.

* HEADER * PROPERTY * CONTENT * VARIABLE

Date String

If you select "CONTENT" from the "Input Type" dropdown you need to provide the date string needs to be used as the input date

Variable Name

If you select "VARIABLE" from the "Input Type" dropdown you need to provide name of the scope variable which needs to be used as the input date

Variable Type

If you select "VARIABLE" from the "Input Type" dropdown you need to provide type of the scope variable by selecting from dropdown menu, ie: whether it is going to be a "STRING" or a "DATE"

Header Name

If you select "HEADER" from the "Input Type" dropdown you need to provide name of the transport header which needs to be used as the input date

Property Name

If you select "PROPERTY" from the "Input Type" dropdown you need to provide name of the message property which needs to be used as the input date

Property Type

If you select "PROPERTY" from the "Input Type" dropdown you need to provide type of the message property by selecting from dropdown menu, ie: whether it is going to be a "STRING" or a "DATE"

Original Date Pattern

If you are providing a date string then it is required to provide the pattern of the provided date string. From the dropdown list you should select on the following date patterns supported by org.apache.commons.lang3.time.FastDateFormat

* yyyy-MM-dd’T’HH:mm:ss * yyyy-MM-dd’T’HH:mm:ssZZ * yyyy-MM-dd * yyyy-MM-ddZZ * 'T’HH:mm:ss * 'T’HH:mm:ssZZ * HH:mm:ss * HH:mm:ssZZ * EEE, dd MMM yyyy HH:mm:ss Z

Date Pattern to be Transformed

Here you need to select the new date format to be transformed from the provided date. Following are the standard formats supported by the org.apache.commons.lang3.time.FastDateFormat

* yyyy-MM-dd’T’HH:mm:ss * yyyy-MM-dd’T’HH:mm:ssZZ * yyyy-MM-dd * yyyy-MM-ddZZ * 'T’HH:mm:ss * 'T’HH:mm:ssZZ * HH:mm:ss * HH:mm:ssZZ * EEE, dd MMM yyyy HH:mm:ss Z

Output Type

Using this property you need to define how you needs to assign the transformed date string. From the dropdown menu you will be able to select one of the following options.

* HEADER * PROPERTY * VARIABLE

Variable Name to Assign Transformed Date

If you select "VARIABLE" from the "Output Type" dropdown you need to provide name of the scope variable which needs to be used to assign the transformed date string

Header Name to Assign Transformed Date

If you select "HEADER" from the "Output Type" dropdown you need to provide name of the transport header which needs to be used to assign the transformed date string

Property Name to Assign Transformed Date

If you select "PROPERTY" from the "Output Type" dropdown you need to provide name of the message property which needs to be used to assign the transformed date string

Sample Use Case

The following simple use case describes how you can receive a HTTP message which contains a transport header with a timestamp value and how you can transform it to a different date format and use in your custom logic. In this case reformatted date string will be assigned to a message context scope variable.

date format transform flow

In the above flow, through HTTP Ingress Connector element messages will be received to the flow. Each message will have a transport header "timestamp" that contains a date value formatted into "yyyy-MM-dd’T’HH:mm:ss". From that date Date Format Transformer processing element will transform the date into "EEE, dd MMM yyyy HH:mm:ss Z" format and assign it to a scope variable of name "transformedDate".

Following images depicts configuration of the processing element.

date transform inputs
date transform outputs

After transformation, transformed date string will be assigned to a scope variable as depicted in the following image.

date transform results

After transformation, in this simple message flow, the message will be forwarded to the backend server through a HTTP Egress Connector.

In this topic
In this topic
Contact Us