Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Daylight saving time

Hi everybody,
as you may know, we change time this sunday (+1 hour). This causes me trouble cause I am working with dates (and especially diffDate). The problem is the following:
dateend=TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", "2012-03-26 00:00:00");
datestart=TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", "2012-03-25 00:00:00");
row1.test=TalendDate.diffDate(datestart, dateend,"ss");
//will return -82800 (86400 seconds - 3600)

whereas:
dateend=TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", "2012-03-27 00:00:00");
datestart=TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", "2012-03-26 00:00:00");
row1.test=TalendDate.diffDate(datestart, dateend,"ss");
//will return 86400 seconds

So I try to develop a routine to have a corrected date. The idea is to add one hour if the day is a sunlight saving one:
package routines;
import java.util.Date;
import routines.TalendDate;
public class CustomOperations {
public static Date correctTimeOffset(Date stupidDate)
{
Date stupidDateMinusOne;
Date correctedDate;

correctedDate=stupidDate;
stupidDateMinusOne=TalendDate.addDate(stupidDate, -1, "dd");

if ( Math.abs(TalendDate.diffDate(stupidDate, stupidDateMinusOne))<86400 )
{
correctedDate=TalendDate.addDate(stupidDate, 1, "hh");
}
return correctedDate;
}

but it does not work (problems with types). Any idea ?
Still, I do not know whether it is the right way to proceed: I fear that if I add 1 hour to the day, it will return the following day... no ?
Labels (3)
11 Replies
Anonymous
Not applicable
Author

Hi everybody,
finally found a workaround solution: I execute my job with the following JVM parameter: -Duser.timezone=UTC
no more dst problems then !
thanks for your support though
Anonymous
Not applicable
Author

Hi
Great! Thanks for your feedback.
Regards,
Pedro