how to get time of different timezones.

Hi, I have a requirement where I need to display timings of different timezones of the world using timezone parameter, can someone help me out how this can be achieved. Is there any inbuilt functionality in mendix? Thanks
3 answers

You could create a java action "FormatDateTimeWithTimeZone” that converts a DateTime to any time zone:

TimeZone tz = TimeZone.getTimeZone(timeZone);
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
String result = sdf.format(date);

It takes parameters timeZone (string), pattern (string) and date (DateTime).


You can use a non-localized timezone and add or subtract hours to that using a calculated field for example. But messing with time zones is always tricky..


As addition to Jop’s answer. DatTime is always stored UTC. When set localize to true, it will be converted to the user client timezone when viewed automatically. When you want to show the same value to the same user at the same time with a different time zone, then set localize to false.

In the System module you’ll find the TimeZone entity, which contains the raw offset of the TimeZone. This offset can be used to calculate and display the DateTime value in multiple timezones