Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Capture Invalid Date type Values in tMap reject flow

I have a Talend Job which reads data from Excel File (.xlsx) via tFileInputExcel component.

There is a column Payment_Date which I have defined as type String in the above component. Reason Excel has 3 rows and for all 3 rows value in Payment_Date column are different as shown below

 

Payment_Date
7/1/2019
NULL
4568

 

 

First row is a valid Date

In the second row string "NULL" is not equivalent to null so I am using tReplace component for replacing string "NULL" to null

Post that I am using tJavaRow to capture input data and pass it via output_row as below

 

Below code says if the value from Input is null then pass null in output else if value is a valid date then pass the valid date to the output

output_row.Payment_Date = Relational.ISNULL(input_row.Payment_Date) ? null : TalendDate.parseDateLocale("EEE MMM d HH:mm:ss zzz yyyy", input_row.Payment_Date, "en");

 

And that in tMap, row6.Payment_Date  (In out-flow of tMap, Payment_Date column is of Date type)

Above approach is working for Valid Date and NULL value but for Invalid Date i.e. 4568 I want that row to be captured in reject flow. But instead, my job fails on tJavaRow with error java.text.ParseException: Unparseable date: "4568"

 

Job flow:

tFileInputExcel  ----main--->tReplace --main---->tJavaRow --main-->tMap---main-->tLogRow

 

Labels (2)
10 Replies
Anonymous
Not applicable
Author

Finally made it work. Thanks @manodwhb For your input. But the issue was not with specifying the correct date format in Source Data but in Expressions and also handling of null value as Valid scenario.

 

Sharing the screenshot of updated settings so that it might help someone with a similar type of issue.

 

Expression in Var:

(Relational.ISNULL(row3.Payment_Date) || (!Relational.ISNULL(row3.Payment_Date)) && TalendDate.isDate(row3.Payment_Date,"M/d/yyyy",true) ) 

Expression in ValidDates:

Relational.ISNULL(row3.Payment_Date) ? null :TalendDate.parseDateLocale("M/d/yyyy", row3.Payment_Date, "en") 

0683p000009M6wC.jpgJob_Output0683p000009M6wM.jpgUpdated tMap