<?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: Unix Epoch to Date Redshift Invalid Date Format in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Unix-Epoch-to-Date-Redshift-Invalid-Date-Format/m-p/2266304#M45574</link>
    <description>&lt;P&gt;ffs redshift datatype was DATE and not TIMESTAMP&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2020 12:07:13 GMT</pubDate>
    <dc:creator>MattE</dc:creator>
    <dc:date>2020-01-28T12:07:13Z</dc:date>
    <item>
      <title>Unix Epoch to Date Redshift Invalid Date Format</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Unix-Epoch-to-Date-Redshift-Invalid-Date-Format/m-p/2266303#M45573</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I've written a java routine to convert from Unix epoch to a java date&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;//java routine
    public static Date unixTimestampToDate(String ts, Boolean isMs) {
		Date date;
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		try {
		
			if(!isMs){
				date = new Date(Long.parseLong(ts));
				return format.parse(date.toString());
			} else {
				return date = new Date(Long.parseLong(ts)*1000);	
			}
		} catch (ParseException e) {
			return date = new Date(Long.parseLong(ts));
		}
	}&lt;/PRE&gt; 
&lt;P&gt;I call this in a tMap with the output column set to Date&amp;nbsp;"yyyy-MM-dd HH:mm:ss"&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The incoming value is&amp;nbsp;1579478403484 which according to &lt;A href="https://www.epochconverter.com/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://www.epochconverter.com/&lt;/A&gt;&amp;nbsp;should be&amp;nbsp;&lt;SPAN&gt;Monday, January 20, 2020 12:00:03.484 AM. I can confirm this conversion is happening correctly by putting a tLogRow on the output of the tMap and seeing the following in the console&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;2020-01-20 00:00:03&lt;/PRE&gt; 
&lt;P&gt;However when i run the job i get the error&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;java.sql.SQLException: [Amazon](500310) Invalid operation: Load into table 'staging_adzerk_requests' failed.  Check 'stl_load_errors' system table for details.;&lt;/PRE&gt; 
&lt;P&gt;on checking&amp;nbsp;stl_load_errors i can see that redshift is complaining of&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;2020-01-20&lt;STRONG&gt; 0024:00:02&lt;/STRONG&gt;&amp;nbsp; - Invalid Date Format - length must be 10 or more&lt;/PRE&gt; 
&lt;P&gt;It looks like Talend is formatting the date wrong in the tDBOutputBulkExec even though i also have that set to&amp;nbsp;"yyyy-MM-dd HH:mm:ss".&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Anyone any ideas how to fix this?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 03:28:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Unix-Epoch-to-Date-Redshift-Invalid-Date-Format/m-p/2266303#M45573</guid>
      <dc:creator>MattE</dc:creator>
      <dc:date>2024-11-16T03:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Epoch to Date Redshift Invalid Date Format</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Unix-Epoch-to-Date-Redshift-Invalid-Date-Format/m-p/2266304#M45574</link>
      <description>&lt;P&gt;ffs redshift datatype was DATE and not TIMESTAMP&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 12:07:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Unix-Epoch-to-Date-Redshift-Invalid-Date-Format/m-p/2266304#M45574</guid>
      <dc:creator>MattE</dc:creator>
      <dc:date>2020-01-28T12:07:13Z</dc:date>
    </item>
  </channel>
</rss>

