Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to convert String to date in talend

hi,
i have date which is in string "MM/dd/yyyy" and i want to convert same format in DATE data type in talend,
means
"MM/dd/yyyy" data type(String) ---> MM/dd/yyyy data type(DATE)
how could i do this please provide the solution.
thanks and regards
Shailendra Shukla

Labels (2)
67 Replies
Anonymous
Not applicable
Author

Hi
You can use routine function TalendDate.parseDate("MM/dd/yyyy", yourStringData) to convert a string to a Date, for example:
tFileInputDelimited--main--tJavaRow--tlogRow
on tJavaRow:
outout_row.columnName=TalendDate.parseDate("MM/dd/yyyy", input_row.columnName);
If you want to learn more about the built in function TalendDate.parseDate("MM/dd/yyyy", yourStringData), expand Code node in Repository, then Routine, System.
Shong
Anonymous
Not applicable
Author

Hi,
And use TalendDate.parseDate(String, String) method in tMap or tConvertType component.
See my screenshots
Best regards
Sabrina
0683p000009M9Yj.jpg 0683p000009MALV.jpg
Anonymous
Not applicable
Author

hi Xdshi,
thanks for your response but when i am using this format as u gave in the snap shot .
it throws an error like..
Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "23.09.2011"
at routines.TalendDate.parseDate(TalendDate.java:643)
at ok.date_formate_0_1.DATE_FORMATE.tFileList_1Process(DATE_FORMATE.java:7544)
at ok.date_formate_0_1.DATE_FORMATE.runJobInTOS(DATE_FORMATE.java:10340)
at ok.date_formate_0_1.DATE_FORMATE.main(DATE_FORMATE.java:10194)
Caused by: java.text.ParseException: Unparseable date: "23.09.2011"
at java.text.DateFormat.parse(Unknown Source)
at routines.TalendDate.parseDate(TalendDate.java:641)
... 3 more
i used this format --TalendDate.parseDate("MM/dd/yyyy",row1.Clearing_Date)
thanks and regards
Shailendra shukla
Anonymous
Not applicable
Author

Hi,
If your input string is 23.09.2011, you should change the format as TalendDate.parseDate("MM.dd.yyyy",row1.Clearing_Date).
Best regards
Sabrina
0683p000009MALa.jpg
Anonymous
Not applicable
Author

23.09.2011 looks like dd.MM.yyyy format 0683p000009MACn.png
Anonymous
Not applicable
Author

Hi,
Sorry for the error. It is TalendDate.parseDate("dd.MM.yyyy",row1.Clearing_Date) for data 23.09.2011.
Thanks for correction.
@shailendra.shukla, is your input MM/dd/yyyy string?
Best regards
Sabrina
Anonymous
Not applicable
Author

Thanks Xdshi ,
yup my input date in string, now its working.
but i want the output in MM/dd/YYYY but it gives as input format
and output is look like -
09/30/2011--->30-SEP-11
but i want in MM/dd/yyyy
i used this format
(Var.date==null || Var.date.isEmpty())? null : TalendDate.parseDate("MM/dd/yyyy",TalendDate.formatDate("MM/dd/yyyy",TalendDate.parseDate("MM/dd/yyyy",Var.date)))
regards
shailendra shukla
Anonymous
Not applicable
Author

Hi,
Show me your tMap editor screenshot so that I can get your current situation more precisely, please.
Best regards
Sabrina
Anonymous
Not applicable
Author

sorry but i m unable to take screenshot, but i used below format
(Var.date==null || Var.date.isEmpty())? null : TalendDate.parseDate("MM/dd/yyyy",TalendDate.formatDate("MM/dd/yyyy",TalendDate.parseDate("MM/dd/yyyy",Var.date)))
and gave date pattern like MM/dd/yyyy.
my input date is MM/dd/yyyy.
after executing the job the output is look like. 09/30/2011(input)--->30-SEP-11(output)