0

I assume that this can only be done with the use of a Field Calculator processor. However, there is little documentation about how to insert functions and about date- and time transformation in particular.

At the moment, the data comes in like this:

"lastUpdated":148043564

It is a double datatype. With the use of a fieldmapper I extracted this field into a custom definition. The new field is of a double datatype too (too prevent problems). This works well, however, I would like to add a new field to the incoming stream of data. This new field must have a 'human-readable' datetime value, like e.g. YYYY/MM/DD HH/MM/SS. What function do I need to fill in to achieve this and how? I'm assuming that my new field has to be of a date character.

  • Take a look at this post: geonet.esri.com/thread/103654# and also a post from RJ in GeoEvent team here: gis.stackexchange.com/questions/140343/… – Simon Nov 29 '16 at 13:32
  • Can you provide a bit more info about the input connector used (and any settings around expected date format), if your geoevent def has a date destination field and what calculation you want to perform on this incoming datetime (edit your question) – Simon Nov 29 '16 at 13:36
  • @Simon I've updated my post – Coopernicus Nov 29 '16 at 16:53
1

The GeoEvent team provided me some info that might help answer your issue:

At the moment, the data comes in like this:
"lastUpdated":148043564"

That’s an epoch long integer expressed in seconds (I assume). So first they need to specify the GeoEvent Definition used by their inbound connector treat this attribute field as a ‘Date’ (not a ‘Double’). If you bring the attribute value in as Double it will forever be Double (not a Date) and you’ll have a hard time changing it.

They could then develop a custom processor which leverages java.text.SimpleDateFormat to convert the Date to a String … but I’m assuming they want an out-of-the-box solution.

GeoEvent expects all date/time epochs to be expressed in milliseconds, not seconds. Lucky for us scaling the date/time value is pretty simple. Once you have 148043564 being handled as a Date you can configure a Field Calculator with an expression myDateTimeEpoch * 1000 and write the result back into the field myDateTimeEpoch. This is how you scale the date/time from seconds to milliseconds … 148043564 becomes 148043564000.

This trick only works because, under the hood, GeoEvent is handling Date types consistent with Java which represents them as long integer epoch values. This is also why I can add a “five hours of milliseconds” to a Date in order to artificially push the value from one time zone to another.

The only way (out-of-the-box) to convert a Date to a “human readable” String is to allow an outbound Text adaptor to create a representation of the date/time as a formatted string for you. That means you have to send the event record to an output – like a TCP/Text output.

If you need to apply additional real-time analytics on the event record before obtaining the String representation of the date/time, you have to do that before sending the event record to the output … or figure out how to “output” the event and then re-ingest it for additional processing by another GeoEvent Service (this can get rather messy).

The JSON outbound adapter maintains Date data as epoch long integers. So you must use an outbound connector which leverages the Text adaptor if you want to create a human readable value from a Date.

  • Thus, an "in-of-the-box" solution isn't possible? – Coopernicus Nov 30 '16 at 11:15
  • I think this is entirely do-able without having to develop a custom processor. Have you tried changing your input geoevent defintion for that field to be a date instead of a double? And where are you persisting this? For example a feature service will successful deal with an epoch value and then you can format the date however you like at the other end. – Simon Nov 30 '16 at 23:51
  • Yes, I tried that but unfortunately without the result wished for. In addition to that, it looks like the functions that can be inserted in the Field Calculator processor are limit to those that are listed in the documentation. There is nothing about date/time transformations. I tried functions for the purpose of transforming an epoch to a readable datetime that are used in Python and Java, but they kept giving me 'null' or '0.00'. – Coopernicus Dec 1 '16 at 7:41
  • I would like to suggest you break your service into a simple one concerning the dates and include a screenshot. Not sure if I will have time, but perhaps also setup a simple service outputting your content to a CSV and include a link to it in your Q. We can use this to simulate running the data through a service at our end. Perhaps also export just your service, geoevent def and used connectors to .XML so we can import them. Also take a look at these posts that maniuplate dates with field calcs geonet.esri.com/thread/93232 and geonet.esri.com/thread/91519 – Simon Dec 1 '16 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.