How to convert date to a single type in a Painless script?

It's required for https://github.com/elastic/kibana/pull/25379
I need to access a date field in a Painless script, but I don't know what its type is.
I know there are at least two possible types - Long (epoch milliseconds) and JodaCompatibleZonedDateTime. Probably there are more.
So I need some way to convert date from one of possible types to a single type.
The method org.elasticsearch.xpack.core.watcher.support.WatcherDateTimeUtils#convertToDate does similar thing, but it's not available inside a Painless script.

If there is no such functionality, I can try to add it.

I believe the concerns here have been addressed in (https://github.com/elastic/elasticsearch/issues/41936).

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.