<?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: IF condition tjava in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/IF-condition-tjava/m-p/2337978#M106267</link>
    <description>&lt;PRE&gt;import java.util.regex.*;

String fname1= "AAA_BBBB_CCC_DDD_20180101_1233.xml";
String fname2= "AAA_20010101_0833_foo.xml";
Matcher m1 = Pattern.compile(".*([0-9]{8}_[0-9]{4}).*").matcher(fname1);
Matcher m2 = Pattern.compile(".*([0-9]{8}_[0-9]{4}).*").matcher(fname2);
if(m1.matches() &amp;amp;&amp;amp; m2.matches())
{
    System.out.println("dt file1: " + m1.group(1));
    System.out.println("dt file2: " + m2.group(1));
}&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 May 2018 14:01:11 GMT</pubDate>
    <dc:creator>Jesperrekuh</dc:creator>
    <dc:date>2018-05-22T14:01:11Z</dc:date>
    <item>
      <title>IF condition tjava</title>
      <link>https://community.qlik.com/t5/Talend-Studio/IF-condition-tjava/m-p/2337977#M106266</link>
      <description>&lt;P&gt;Hello everyone, I'm trying to compare filename with date inside to whether or not delete them.&lt;/P&gt; 
&lt;P&gt;Since I have 2 types of filesname : "AA_MAGAS_yyyyMMdd_hhmm" and "AA_BBB_CCC_yyyyMMdd_hhmm" , my idea was to substring the filename (from 9 to 22 for first file type and 11 to 24 for the second one), get the date out &amp;amp; compare it. Then use this result in a run if condition to delete it.&lt;/P&gt; 
&lt;P&gt;My job was working for only 1 file type, but since I tried a IF condition to deal with the 2 filesname, its not working anymore. Can someone have a check ?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;if ( ((String)globalMap.get("tFileList_1_CURRENT_FILE")).equals("AA_MAGAS_*") )

{
	
context.strdate = ((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(9,22);

context.date = TalendDate.parseDate("yyyyMMdd_hhmm",context.strdate);

//difference of days between current date &amp;amp; file date, &amp;gt;15 = delete (runif)

context.difference = TalendDate.diffDate(TalendDate.getCurrentDate(),context.date,"dd");

}

else {
	

context.ecodate = ((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(11,24);

context.date = TalendDate.parseDate("yyyyMMdd_hhmm", context.ecodate);

context.difference = TalendDate.diffDate(TalendDate.getCurrentDate(),context.date,"dd");


};&lt;/PRE&gt; 
&lt;P&gt;&lt;BR /&gt;My error, seems like the IF condition is not working because the substring get it wrong :&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;java.lang.RuntimeException: java.text.ParseException: Unparseable date: "180210_0345.x"&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 10:33:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/IF-condition-tjava/m-p/2337977#M106266</guid>
      <dc:creator>daez</dc:creator>
      <dc:date>2018-05-22T10:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: IF condition tjava</title>
      <link>https://community.qlik.com/t5/Talend-Studio/IF-condition-tjava/m-p/2337978#M106267</link>
      <description>&lt;PRE&gt;import java.util.regex.*;

String fname1= "AAA_BBBB_CCC_DDD_20180101_1233.xml";
String fname2= "AAA_20010101_0833_foo.xml";
Matcher m1 = Pattern.compile(".*([0-9]{8}_[0-9]{4}).*").matcher(fname1);
Matcher m2 = Pattern.compile(".*([0-9]{8}_[0-9]{4}).*").matcher(fname2);
if(m1.matches() &amp;amp;&amp;amp; m2.matches())
{
    System.out.println("dt file1: " + m1.group(1));
    System.out.println("dt file2: " + m2.group(1));
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 14:01:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/IF-condition-tjava/m-p/2337978#M106267</guid>
      <dc:creator>Jesperrekuh</dc:creator>
      <dc:date>2018-05-22T14:01:11Z</dc:date>
    </item>
  </channel>
</rss>

