convert string to datetime for csv file

One Star

convert string to datetime for csv file

Hi,
I have a csv file contain string date '12/2/2012 5:47'. I convert to datetime but I got this error Unparseable date: "12/2/2012 5:47"
I try to save the file to excel it work. but for csv it become an error.
Please anyone help me....
Regards,
Ommie
Moderator

Re: convert string to datetime for csv file

Hi omie,
I have designed a demo job and made a testing for it. The job works well. Could you give us more info, such as your job screenshots and Date pattern so that we can address your issue quickly.
See my job screenshots as follows:
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: convert string to datetime for csv file

Hi Sabrina,
my date data sample is like this:
12/2/2012 0:00
12/2/2012 0:00
12/2/2012 0:00
12/2/2012 0:01
I already try the way what you did but got error :
java.lang.NumberFormatException: For input string: "12/2"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at routines.system.FastDateParser$DateTimeParser.parse(FastDateParser.java:206)
at routines.system.ParserUtils.parseTo_Date(ParserUtils.java:208)
at uc.testdate_0_1.testDate$1RowHelper_tFileInputDelimited_1.valueToConn(testDate.java:992)
at uc.testdate_0_1.testDate.tFileInputDelimited_1Process(testDate.java:1147)
at uc.testdate_0_1.testDate.runJobInTOS(testDate.java:1566)
at uc.testdate_0_1.testDate.main(testDate.java:1434)
Unparseable date: "12/2/2012 0:00"
Do you have any idea? For excel source file it work fine but only for csv file got error for date..
Regards,
Ommie
Moderator

Re: convert string to datetime for csv file

Hi,
Everything is OK on my version Talend Open Studio for Data Integration(5.2.1r95165). How about checking out the option "Trim all column" in the advance setting of tFileInputDelimited component and make sure that there is no extra space in your "Date pattern"
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.