Select to view content in your preferred language

Formatting the date in the MessageFormatter adapter (outbound)

4520
3
09-10-2014 08:07 AM
GTiemens
Deactivated User

I have an incoming event through the FeatureService input. 2 Fields are marked as Date.

How can I format these dates into the right format.

TCP-out displays the date formatted like this:

Wed Sep 10 16:16:57 CEST 2014

MessageFormatter displays the date formatted the same way this (just another date/time);

Tue Sep 09 16:08:35 CEST 2014

I want to have this format:

2014-09-10 14:07:42

With the SimpleDateFormatter, it would be this format:

"yyyy-MM-dd HH:mm:ss"

Can I use a Calculate Field processor to format the field to a string field?

Tags (1)
0 Kudos
3 Replies
KDeVogelaere
Deactivated User

Hi G Tiemens,

I have used the Field Calculator to convert input timestamps into local time, but I haven't tried converting dates with the month names in them. There are some helpful tips on this post that will help get you started,

Converting between Date Formats

Your process flow may have to ingest the date field into an output feature service that can return a numeric date back into GEP, once the date is back in GEP your Field Calculator can parse the numeric value into the format you are expecting.

Converting date format  'DDMMYY hhmmss' to 'YYYY-MM-DDThh:mm:ssZ' use,

'20' + substring(input_date,4,6)+ '-' + substring(input_date,2,4) + '-' + substring(input_date,0,2) + 'T' + substring(input_date,0,2) + ':' + substring(input_date,2,4) + ':' + substring(input_date,4,6) + 'Z'

0 Kudos
RJSunderman
Esri Regular Contributor

Prior to the 10.3 release, if you wanted to output a custom string representation of a date/time value, you would have to follow a process like K DeVogelaere suggests above. Polling event data from a feature service for input, as G Tiemans indicates, and bringing the date/time values into GeoEvent using the Date data type prevents you from later obtaining the days / months / years or hours / minutes / seconds values from the Date.

GeoEvent does not provide an interface like you might find in Java (illustrated below) to pull discrete values out of a Date:

Capture1.png

Thus, you would have to broadcast the Date value out a GeoEvent output and re-ingest it as a String in order to use the substring() function supported by the Field Calculator processor for string manipulation. You cannot bring the date/time in from the feature service as a String because the feature service's JSON represents the date/time as a long integer in epoch milliseconds.

0 Kudos
RJSunderman
Esri Regular Contributor

Beginning with the 10.3 product release you have some additional options available.

Enhancements to the Text adapter -- used by the 'Push Text to an External TCP Socket' and 'Write to a CSV File' out-of-the-box connectors -- allow you to specify that you want a custom String representation of a Date:

Capture1.png

The configuration is usually found beneath the 'Advanced' properties of the connector, as illustrated above.

This feature is not supported on the MessageFormatter adapter, used by outbound connectors such as 'Send a Text Message' or 'Send an Email'. The enhancement was only made for the Text adapter.

Hope this information helps -

RJ