This is a great question.
I have built a Java action that can behave in a similar way to the built in formatDateTime method, but also take a time zone string parameter. e.g. ‘Europe/London’, and return the time from another time zone to the user.
This uses the built in Java time and timezone classes, no external API necessary. It does require Mendix 8.6.9 or above though.
It’s available on my GitHub. https://github.com/robertprice/DateTimeWithZones
If you don’t want the example project and unit tests, just download the stand alone module from the releases folder and import into your own project.
I’m thinking of refining this a bit more and releasing it on the Marketplace.
I know dates and times have lots of gotchas, so I’m interested in any feedback / bugs.
A couple of ideas:
I don't think there's a built-in way sadly, and (as I'm sure you've already considered) it's not as easy as just adding x hours to the UTC time as you might need to deal with summertime / wintertime and such. Looked into it, and this free timezone API might work if you don't need too many requests at a time?
Edit: Alternatively, combine these approaches to figure out summer / wintertime with the API (call it once per hour for the timezones you need to check out the time difference to UTC) and then use the addHours approach.
Edit: There are several Java libraries available like java.time.* to convert dates to different timezones.
Other than trying to build one’s own logic, one option is to use the API for time conversion, I definitely would use these, if the transaction volume is going to be low.