<?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: Parsing string date from a filename in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Parsing-string-date-from-a-filename/m-p/2236087#M24924</link>
    <description>&lt;P&gt;If you can guarantee your incoming format will always be consistent the following will work in a tJavaRow component:&lt;/P&gt; 
&lt;PRE&gt;String data = row1.data;
row2.start = data;

//extract date from string
String extracted = data.substring(data.indexOf("_",data.indexOf("_") + 1) + 1,data.indexOf("-"));
row2.extracted = extracted;

//extract date formatted
Date d = TalendDate.parseDate("MMMdd_yyyy", extracted);

row2.finalDate = TalendDate.formatDate("yyyy-MM-dd", d);&lt;/PRE&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2018-10-02_15-58-34.png" style="width: 843px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M09Q.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/130993iB70660BD2E2F7201/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M09Q.png" alt="0683p000009M09Q.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Oct 2018 20:59:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-10-02T20:59:27Z</dc:date>
    <item>
      <title>Parsing string date from a filename</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Parsing-string-date-from-a-filename/m-p/2236086#M24923</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have a file with the following format:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;203147_TMBreakdown_Aug29_2018-Aug31_2018_20180901&lt;/P&gt; 
&lt;P&gt;204780_TMBreakdown_Sep17_2018-Sep18_2018_20180920&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I'd like to parse out the first date in the filename as YYYY-MM-DD or DD/MM/YY&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In the two filenames above:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Aug29_2018 ----&amp;gt; 2018-08-29 or 29/08/18&lt;/P&gt; 
&lt;P&gt;Sep17_2018 ----&amp;gt; 2018-09-17 or 17/09/18&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Could anyone help me on how to do this? I'm fairly new to Talend.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 19:34:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Parsing-string-date-from-a-filename/m-p/2236086#M24923</guid>
      <dc:creator>gusilu</dc:creator>
      <dc:date>2018-10-02T19:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing string date from a filename</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Parsing-string-date-from-a-filename/m-p/2236087#M24924</link>
      <description>&lt;P&gt;If you can guarantee your incoming format will always be consistent the following will work in a tJavaRow component:&lt;/P&gt; 
&lt;PRE&gt;String data = row1.data;
row2.start = data;

//extract date from string
String extracted = data.substring(data.indexOf("_",data.indexOf("_") + 1) + 1,data.indexOf("-"));
row2.extracted = extracted;

//extract date formatted
Date d = TalendDate.parseDate("MMMdd_yyyy", extracted);

row2.finalDate = TalendDate.formatDate("yyyy-MM-dd", d);&lt;/PRE&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2018-10-02_15-58-34.png" style="width: 843px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M09Q.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/130993iB70660BD2E2F7201/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M09Q.png" alt="0683p000009M09Q.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 20:59:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Parsing-string-date-from-a-filename/m-p/2236087#M24924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-02T20:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing string date from a filename</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Parsing-string-date-from-a-filename/m-p/2236088#M24925</link>
      <description>&lt;P&gt;Thank you so much! I will try this as soon as I get home.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 19:16:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Parsing-string-date-from-a-filename/m-p/2236088#M24925</guid>
      <dc:creator>gusilu</dc:creator>
      <dc:date>2018-10-03T19:16:38Z</dc:date>
    </item>
  </channel>
</rss>

