<?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: Adding the local Date-Time without Time Zone in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310634#M81741</link>
    <description>The java Date object has no concept of timezone. The issue is converting the Date either using SimpleDateFormat or Date.toString(). In this case, it uses the local timezone in order to translate the Date (which is nothing more than the number of milliseconds since January 1st 1970, UTC) into a formatted date string. 
&lt;BR /&gt;Your best bet is to write a custom code routine and modify the TalendDate.getDate() code. You will need to set the TimeZone in the Calendar instance. For example: 
&lt;BR /&gt;replace this part of the code: 
&lt;BR /&gt; 
&lt;PRE&gt;        SimpleDateFormat sdf = new SimpleDateFormat(pattern);&lt;BR /&gt;        sdf.format(Calendar.getInstance().getTime(), result, new FieldPosition(0));&lt;BR /&gt;        return result.toString();&lt;/PRE&gt; 
&lt;BR /&gt;with this: 
&lt;BR /&gt; 
&lt;PRE&gt;        SimpleDateFormat sdf = new SimpleDateFormat(pattern);&lt;BR /&gt;        sdf.format(Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(), result, new FieldPosition(0));&lt;BR /&gt;        return result.toString();&lt;/PRE&gt;</description>
    <pubDate>Fri, 05 Jul 2013 21:47:31 GMT</pubDate>
    <dc:creator>TXAggie00</dc:creator>
    <dc:date>2013-07-05T21:47:31Z</dc:date>
    <item>
      <title>Adding the local Date-Time without Time Zone</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310633#M81740</link>
      <description>Hi,&lt;BR /&gt;in a tMap I need to write the DateTime String, but without Timezone. It means the Greenwitch time.&lt;BR /&gt;The TalendDate.getDate("yyyy-MM-dd HH:mm:ss") geve to me the local time, obviously.&lt;BR /&gt;Thank you,&lt;BR /&gt;regards.</description>
      <pubDate>Fri, 05 Jul 2013 17:05:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310633#M81740</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-05T17:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the local Date-Time without Time Zone</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310634#M81741</link>
      <description>The java Date object has no concept of timezone. The issue is converting the Date either using SimpleDateFormat or Date.toString(). In this case, it uses the local timezone in order to translate the Date (which is nothing more than the number of milliseconds since January 1st 1970, UTC) into a formatted date string. 
&lt;BR /&gt;Your best bet is to write a custom code routine and modify the TalendDate.getDate() code. You will need to set the TimeZone in the Calendar instance. For example: 
&lt;BR /&gt;replace this part of the code: 
&lt;BR /&gt; 
&lt;PRE&gt;        SimpleDateFormat sdf = new SimpleDateFormat(pattern);&lt;BR /&gt;        sdf.format(Calendar.getInstance().getTime(), result, new FieldPosition(0));&lt;BR /&gt;        return result.toString();&lt;/PRE&gt; 
&lt;BR /&gt;with this: 
&lt;BR /&gt; 
&lt;PRE&gt;        SimpleDateFormat sdf = new SimpleDateFormat(pattern);&lt;BR /&gt;        sdf.format(Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(), result, new FieldPosition(0));&lt;BR /&gt;        return result.toString();&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jul 2013 21:47:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310634#M81741</guid>
      <dc:creator>TXAggie00</dc:creator>
      <dc:date>2013-07-05T21:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the local Date-Time without Time Zone</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310635#M81742</link>
      <description>The way I came up with to do this is:
&lt;BR /&gt;
&lt;PRE&gt;Calendar c = Calendar.getInstance();&lt;BR /&gt;TimeZone tz = c.getTimeZone();&lt;BR /&gt;Long ms = c.getTimeInMillis();&lt;BR /&gt;Date dt = new Date(ms-tz.getOffset(ms));&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Jul 2013 10:05:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310635#M81742</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2013-07-07T10:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the local Date-Time without Time Zone</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310636#M81743</link>
      <description>&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;The java Date object has no concept of timezone. The issue is converting the Date either using SimpleDateFormat or Date.toString(). In this case, it uses the local timezone in order to translate the Date (which is nothing more than the number of milliseconds since January 1st 1970, UTC) into a formatted date string. &lt;BR /&gt;Your best bet is to write a custom code routine and modify the TalendDate.getDate() code. You will need to set the TimeZone in the Calendar instance. For example:&lt;BR /&gt;replace this part of the code:&lt;BR /&gt;&lt;PRE&gt;        SimpleDateFormat sdf = new SimpleDateFormat(pattern);&lt;BR /&gt;        sdf.format(Calendar.getInstance().getTime(), result, new FieldPosition(0));&lt;BR /&gt;        return result.toString();&lt;/PRE&gt;&lt;BR /&gt;with this:&lt;BR /&gt;&lt;PRE&gt;        SimpleDateFormat sdf = new SimpleDateFormat(pattern);&lt;BR /&gt;        sdf.format(Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(), result, new FieldPosition(0));&lt;BR /&gt;        return result.toString();&lt;/PRE&gt;&lt;BR /&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;Thank you. How Can I do this? Sorry, I've not modified the code in Talend. 
&lt;BR /&gt; 
&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;The way I came up with to do this is:&lt;BR /&gt;&lt;PRE&gt;Calendar c = Calendar.getInstance();&lt;BR /&gt;TimeZone tz = c.getTimeZone();&lt;BR /&gt;Long ms = c.getTimeInMillis();&lt;BR /&gt;Date dt = new Date(ms-tz.getOffset(ms));&lt;/PRE&gt;&lt;BR /&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;Can I use this code to a tJava and assign to a context variable? 
&lt;BR /&gt;EDIT: SOLVED with alevy's solution. I've created a routine with a simple class who implements the method. Then I callend him in tJava. 
&lt;BR /&gt;Only one question. If I want to consider Time Zone in addition to uneversal Time?</description>
      <pubDate>Mon, 08 Jul 2013 08:22:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310636#M81743</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-08T08:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the local Date-Time without Time Zone</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310637#M81744</link>
      <description>How do you mean?</description>
      <pubDate>Mon, 08 Jul 2013 19:19:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Adding-the-local-Date-Time-without-Time-Zone/m-p/2310637#M81744</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2013-07-08T19:19:35Z</dc:date>
    </item>
  </channel>
</rss>

