[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)

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)
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..