How do I know if DST is active?

1
I need to know if DST is active by using a microflow. I want to build a microflow which returns a boolean after performing a simple check if DST is active at the current time. Who know how I can check that?
asked
3 answers
3

With a little java code. Create a java action that has a string input for the timezone (e.g. CET) and a datetime input for the date to check, the return value is boolean true for DST, false if not DST. Then in the java code:

        // BEGIN USER CODE
    TimeZone tz = TimeZone.getTimeZone(inputTimeZone);
    return tz.inDaylightTime(inputDate);
    // END USER CODE

and make sure to add the following import statement:

import java.util.TimeZone;
answered
5

Since we often get questions about how DateTime is handled in Mendix, I wrote a small FAQ at https://world.mendix.com/display/refguide4/DateTime+handling+FAQ, please let me know if you have any comments or additional questions. It's a work in progress so expect some more questions/answers soon.

Additionally, I created an App Store module called DateTimeLibrary that has a Microflow that returns whether a certain date is in DST for the user/session executing the microflow. No params for the name of the time zone have to be passed.

Note that for users that do not have a time zone set, this will always return false.

Edit: I just updated the module and FAQ. The module now also has a microflow for parsing a date string using a certain time zone.

answered
1

I always count the hours between a datetime in my timezone and an UTC date. If it is one hour you are in wintertime, if it is two hours you are in summertime. This way you do not need java code.

Regards,

Ronald

answered