<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [resolved] Convert Historical UTC Time in Local Time with Daylight Rules in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293101#M66112</link>
    <description>Hello guy&lt;BR /&gt;Can you give us an example to describe your requirment?&lt;BR /&gt;Best</description>
    <pubDate>Mon, 21 Dec 2009 01:50:17 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-12-21T01:50:17Z</dc:date>
    <item>
      <title>[resolved] Convert Historical UTC Time in Local Time with Daylight Rules</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293100#M66111</link>
      <description>Hello,&lt;BR /&gt;exist a java function to convert a UTC Datetime to Lokal Time?&lt;BR /&gt;I want to tell the function a historical date an want to have back the local time.&lt;BR /&gt;The function must check the date and decide it is summertime or wintertime...&lt;BR /&gt;Thanks &lt;BR /&gt;Sebastian1234</description>
      <pubDate>Sat, 16 Nov 2024 13:38:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293100#M66111</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2024-11-16T13:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Convert Historical UTC Time in Local Time with Daylight Rules</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293101#M66112</link>
      <description>Hello guy&lt;BR /&gt;Can you give us an example to describe your requirment?&lt;BR /&gt;Best</description>
      <pubDate>Mon, 21 Dec 2009 01:50:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293101#M66112</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-21T01:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Convert Historical UTC Time in Local Time with Daylight Rules</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293102#M66113</link>
      <description>Hello,&lt;BR /&gt;from a database (MS SQL Server 2008) i retrive data with datetime cols.&lt;BR /&gt;This datetime values are all in UTC.&lt;BR /&gt;On SQL Server exist no function to convert this UTC to Local Time.&lt;BR /&gt;So I think i can do this with a talend build in function. &lt;BR /&gt;There is no function. Ok i can write. But i'm really bad in java.&lt;BR /&gt;Expample Data&lt;BR /&gt;2008-05-13 15:14&lt;BR /&gt;2008-02-13 15:14&lt;BR /&gt;This is UTC. The Function should convert to Europe/Amsterdam.&lt;BR /&gt;2008-05-13 17:14 (Take Attantion of Daylight!! Summertime)&lt;BR /&gt;2008-05-13 16:14&lt;BR /&gt;From the last sunday in march to the last sunday in october it is +2 the rest of time it is +1.&lt;BR /&gt;This only correct for my timezone! &lt;BR /&gt;newfunction_utc_to_localtime("2009-05-13 15:14", "Europe/Amsterdam")&lt;BR /&gt;Can you really help?  &lt;BR /&gt;I do a bad workaround: I export to csv and convert with python, cause im not good in sql and java. &lt;BR /&gt;But this is quick and dirty...</description>
      <pubDate>Mon, 21 Dec 2009 12:55:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293102#M66113</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2009-12-21T12:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Convert Historical UTC Time in Local Time with Daylight Rules</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293103#M66114</link>
      <description>Hello 
&lt;BR /&gt;You can write some jave code to convert UTC to local time, go to 'Repository--&amp;gt;Code--&amp;gt;Routines' and create a new routine, let's calle it as: F9322 and then call this routine on tMap. 
&lt;BR /&gt; 
&lt;PRE&gt;// template routine Java&lt;BR /&gt;package routines;&lt;BR /&gt;import java.util.Date;&lt;BR /&gt;public class F9322 {&lt;BR /&gt;	static java.util.Calendar cal = java.util.Calendar.getInstance();&lt;BR /&gt;	static int zoneOffset = cal.get(java.util.Calendar.ZONE_OFFSET);&lt;BR /&gt;	static int dstOffset = cal.get(java.util.Calendar.DST_OFFSET);&lt;BR /&gt;	public static Date convertUTCtoLocalTime(Date date) {&lt;BR /&gt;		cal.setTime(date);&lt;BR /&gt;		cal.add(java.util.Calendar.MILLISECOND, (zoneOffset + dstOffset));&lt;BR /&gt;		return cal.getTime();&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;BR /&gt;Best regards 
&lt;BR /&gt; 
&lt;BR /&gt; shong</description>
      <pubDate>Tue, 22 Dec 2009 08:16:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293103#M66114</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-22T08:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Convert Historical UTC Time in Local Time with Daylight Rules</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293104#M66115</link>
      <description>Hello,&lt;BR /&gt;YES! This is want i want!&lt;BR /&gt;Thanks for your fast answer.&lt;BR /&gt;I will have a try!&lt;BR /&gt;Sebastian1234</description>
      <pubDate>Wed, 23 Dec 2009 08:15:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293104#M66115</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2009-12-23T08:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Convert Historical UTC Time in Local Time with Daylight Rules</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293105#M66116</link>
      <description>Sorry for replying to an old thread, but thought I'd add to this because I came across this thread in my search to figure out how to convert UTC to Local Time. The code that Shong has provided didn't totally work for me because it's calculating the DSTOffSet based on the current time. Rather, I believe we want to calculate the DSTOffset based on the incoming date that is trying to be converted. At least, for my use case, this is what I believe i need. 
&lt;BR /&gt;So, here's my revised code, note that I put the DSTOffSet calculation after the call to cal.setTime, which I believe now makes the DSTOffset value correct. 
&lt;BR /&gt; 
&lt;BR /&gt;package routines; 
&lt;BR /&gt;import java.util.Date; 
&lt;BR /&gt;public class convert_utc_local { 
&lt;BR /&gt; static java.util.Calendar cal = java.util.Calendar.getInstance(); 
&lt;BR /&gt; static int zoneOffset = cal.get(java.util.Calendar.ZONE_OFFSET); 
&lt;BR /&gt;// static int dstOffset = cal.get(java.util.Calendar.DST_OFFSET); 
&lt;BR /&gt; public static Date convertUTCtoLocalTime(Date date) { 
&lt;BR /&gt; cal.setTime(date); 
&lt;BR /&gt; int dstOffset = cal.get(java.util.Calendar.DST_OFFSET); 
&lt;BR /&gt; cal.add(java.util.Calendar.MILLISECOND, (zoneOffset + dstOffset)); 
&lt;BR /&gt; return cal.getTime(); 
&lt;BR /&gt; } 
&lt;BR /&gt;}</description>
      <pubDate>Wed, 11 Jul 2012 20:17:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293105#M66116</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-07-11T20:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Convert Historical UTC Time in Local Time with Daylight Rules</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293106#M66117</link>
      <description>Got this working: 
&lt;BR /&gt; 
&lt;PRE&gt;// template routine Java&lt;BR /&gt;package routines;&lt;BR /&gt;import java.util.Date;&lt;BR /&gt;public class UserDefined {&lt;BR /&gt;	static java.util.Calendar cal = java.util.Calendar.getInstance();&lt;BR /&gt;	static int zoneOffset = cal.get(java.util.Calendar.ZONE_OFFSET);&lt;BR /&gt;	static int dstOffset = cal.get(java.util.Calendar.DST_OFFSET);&lt;BR /&gt;    /**&lt;BR /&gt;     * convertUTCtoLocalTime: converts a UTC time given to local time&lt;BR /&gt;     * &lt;BR /&gt;     * &lt;BR /&gt;     * {talendTypes} Date&lt;BR /&gt;     * &lt;BR /&gt;     * {Category} User Defined&lt;BR /&gt;     * &lt;BR /&gt;     * {param} date type: The date to convert&lt;BR /&gt;     * &lt;BR /&gt;     * {example} convertUTCtoLocalTime(sysdate) # returns date converted to local time&lt;BR /&gt;     */&lt;BR /&gt;	public static Date convertUTCtoLocalTime(Date date) {&lt;BR /&gt;		cal.setTime(date);&lt;BR /&gt;		cal.add(java.util.Calendar.MILLISECOND, (zoneOffset + dstOffset));&lt;BR /&gt;		return cal.getTime();&lt;BR /&gt;	}&lt;BR /&gt;	&lt;BR /&gt;    /**&lt;BR /&gt;     * convertLocalTimetoUTC: converts a local time given to UTC time&lt;BR /&gt;     * &lt;BR /&gt;     * &lt;BR /&gt;     * {talendTypes} Date&lt;BR /&gt;     * &lt;BR /&gt;     * {Category} User Defined&lt;BR /&gt;     * &lt;BR /&gt;     * {param} date type: The date to convert&lt;BR /&gt;     * &lt;BR /&gt;     * {example} convertLocalTimetoUTC(sysdate) # returns date converted to local time.&lt;BR /&gt;     */&lt;BR /&gt;	public static Date convertLocalTimetoUTC(Date date) {&lt;BR /&gt;		cal.setTime(date);&lt;BR /&gt;		cal.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset));&lt;BR /&gt;		return cal.getTime();&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Sep 2015 14:26:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Convert-Historical-UTC-Time-in-Local-Time-with-Daylight/m-p/2293106#M66117</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-09-11T14:26:25Z</dc:date>
    </item>
  </channel>
</rss>

