I combine two columns; date and time. When I pass the date and time hot coded it works fine but when I pass it through a column it throws the error:
Unparseable date: "05/05/1992"
I already tried this:
MaterialCodeCSV.xdate == null ?
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", TalendDate.getDate("yyyy-MM-dd HH:mm:ss")) :
TalendDate.parseDateLocale("yyyy/mm/dd HH:mm:ss",MaterialCodeCSV.xdate.toString() + MaterialCodeCSV.xtime.toString(),"EN");
Java code in Talend:
Date handling can be a bit tricky if using wrong data types. I assume you want to fill a field which is a
Date
. There are several errors with this way:MaterialCodeCSV.xdate == null
you create a date and parse it again instantly? That seems unneccessary complex and inefficient. Change this toTalendDate.getCurrentDate()
xdate
is not null, you just concatxdate
andxtime
, usetoString()
and try to parse this. Again, this seems unneccesary complex. If I just assume now andxdate
andxtime
are alreadyDate
fields, you could write it as this:MaterialCodeCSV.xdate + MaterialCodeCSV.xtime
.String
fields, you have to make sure thatxdate
is formattedyyyy/MM/dd
andxtime
isHH:mm:ss
. Then you could exclude.toString()
String
fields, you have to add an additional space:MaterialCodeCSV.xdate + ' ' + MaterialCodeCSV.xtime
yyyy-MM-dd HH:mm:ss
. In the second case you parse withyyyy/mm/dd H:mm:ss
. This reads "year/minute/day". Also there is only one hour digit, not allowing anything after 9:59:59 o'clock to be parsed. Correctly you should useyyyy/MM/dd HH:mm:ss
.So to conclude it should look like this (if I assume correctly and you are using correctly formatted
String
fields forxdate
andxtime
):