Unparseable Date error - Talend

2019-09-03 06:16发布

问题:

I am trying to copy data from Excel to a SQL table.

I have dates generated in Excel file using RAND function. I am taking them as strings in an input and trying to convert them in date data type using tConvertType.

I have setted its datatype as 'string' in initial input and as 'date' in tConvertType's output and in tMSSqlOutput.

My job has work flow Excel input -> tConvertType -> tMap -> tMSSqlOutput. While running the job I am getting an error which says : java.text.ParseException: Unparseable date: "Tue Jul 17 00:00:00 EDT 1973"

I am not sure where the problem lies. If anyone could help me with this it would be much appreciated.

Here's the screenshot of my job.

回答1:

i am able to parse your given sample date please use below function in tMap for your date filed.

System.out.println(TalendDate.parseDateLocale("EEE MMM dd HH:mm:ss zzz yyyy", 'Tue Jul 17 00:00:00 EDT 1973', "EN"));

function is yourDateColumn!=null && !"".equalsIgnoreCase(yourDateColumn)? TalendDate.parseDateLocale("EEE MMM dd HH:mm:ss zzz yyyy", yourDateColumn, "EN") :null



回答2:

@UmeshR: your code is working fine, but you have to handle the timezone thing as well. e.g. I am from India and when i converted the time from EDT talend converted it to my local timezone. see the screen-shot.