Scheduled events do not take daylight saving time into account

0
Hi all,   Last weekend in the netherlands daylight saving time started, which means the clock moved back an hour. However, the scheduled event still runs at the same time it previously ran. The scheduled event was set to server time and UTC does not observe daylight saving time. This scheduled event sent a push notification at 10 o'clock in the morning. If it suddenly arrives at 11 o'clock would be strange for our users. So my question is: How do I make sure the scheduled events take daylight saving time into account?
asked
2 answers
2

Create two scheduled events (1 hour different)

In a java-action detect in daylight saving

TimeZone.getDefault().inDaylightTime( new Date() );

Decide which one of the two events/mfs you run.

answered
2

I use a slightly different Java code which has the advantage of passing a date time object to it so you can also check DST in different timezones.

Regards,

Ronald

import com.mendix.systemwideinterfaces.core.UserAction;
import java.util.TimeZone;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;

/**
 * Check if a time zone has DST active. Input is string with timezone like CET and a Date.
 */
public class DSTCheck extends CustomJavaAction<java.lang.Boolean>
{
	private java.lang.String timeZoneString;
	private java.util.Date inputDate;

	public DSTCheck(IContext context, java.lang.String timeZoneString, java.util.Date inputDate)
	{
		super(context);
		this.timeZoneString = timeZoneString;
		this.inputDate = inputDate;
	}

	@Override
	public java.lang.Boolean executeAction() throws Exception
	{
		// BEGIN USER CODE
	    TimeZone tz = TimeZone.getTimeZone(timeZoneString);
	    return tz.inDaylightTime(inputDate);

		// END USER CODE
	}

	/**
	 * Returns a string representation of this action
	 */
	@Override
	public java.lang.String toString()
	{
		return "DSTCheck";
	}

	// BEGIN EXTRA CODE
	// END EXTRA CODE
}

 

answered