[resolved] Unparseable date: "0"

Seven Stars

[resolved] Unparseable date: "0"

Hi,
I'm new to Talend. I'm trying to load delimited (,) file to SQL server table. My input field CURBEGDT has dates with format (yyyyMMdd) as well as some invalid date values like "0". My output table in SQL Db contains CURBEGDT field with datetime data type. To handle invalid dates "0" I'm using tMap with following code :
row2.CURBEGDT.isEmpty() || row2.CURBEGDT == "0"
? TalendDate.getCurrentDate()
: TalendDate.parseDate("yyyyMMdd",row2.CURBEGDT)
But I'm still getting following error. Can somebody please help me? This is ASAP.
Starting job FTP_Daily_Scan at 15:22 30/08/2011.
connecting to socket on port 3727
connected
Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "0"
at routines.TalendDate.parseDate(TalendDate.java:643)
at training___joshi.ftp_daily_scan_0_1.FTP_Daily_Scan.tFileList_1Process(FTP_Daily_Scan.java:2935)
at training___joshi.ftp_daily_scan_0_1.FTP_Daily_Scan.runJobInTOS(FTP_Daily_Scan.java:3808)
at training___joshi.ftp_daily_scan_0_1.FTP_Daily_Scan.main(FTP_Daily_Scan.java:3682)
Caused by: java.text.ParseException: Unparseable date: "0"
at java.text.DateFormat.parse(Unknown Source)
at routines.TalendDate.parseDate(TalendDate.java:641)
... 3 more
disconnected
Job FTP_Daily_Scan ended at 15:22 30/08/2011.

Accepted Solutions
Seven Stars

Re: [resolved] Unparseable date: "0"

You cannot use == with Strings. Change your expression to the following and it should work:
row2.CURBEGDT.isEmpty() || row2.CURBEGDT.equals("0")
? TalendDate.getCurrentDate()
: TalendDate.parseDate("yyyyMMdd",row2.CURBEGDT)

View solution in original post


All Replies
Seven Stars

Re: [resolved] Unparseable date: "0"

You cannot use == with Strings. Change your expression to the following and it should work:
row2.CURBEGDT.isEmpty() || row2.CURBEGDT.equals("0")
? TalendDate.getCurrentDate()
: TalendDate.parseDate("yyyyMMdd",row2.CURBEGDT)

View solution in original post

Seven Stars

Re: [resolved] Unparseable date: "0"

Thanks... that helped. Thank you very much. Smiley Happy
One Star

Re: [resolved] Unparseable date: "0"

Thank you so much.. It helped me alot..

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog