Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
daez
Creator
Creator

IF in tJava issue

Hello everyone, I'm trying to compare filename with date inside to whether or not delete them.

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 & compare it. Then use this result in a run if condition to delete it.

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 ?

 

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 & file date, >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");


};


My error, seems like the IF condition is not working because the substring get it wrong :


java.lang.RuntimeException: java.text.ParseException: Unparseable date: "180210_0345.x"

 

Thanks!

Labels (3)
1 Solution

Accepted Solutions
daez
Creator
Creator
Author

Hello, Thanks its all fine now. We cant use wildcard in equalsIgnoreCase. I had to use substring then equals

View solution in original post

2 Replies
vboppudi
Partner - Creator III
Partner - Creator III

i think issue with file name format, date format in file name looks like yyMMdd_hhmm not yyyyMMdd_hhmm this.

 

Please validate file name.

 

Regards,

daez
Creator
Creator
Author

Hello, Thanks its all fine now. We cant use wildcard in equalsIgnoreCase. I had to use substring then equals