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
Srini2
Contributor
Contributor

Hi All,
please help me in date conversion in talend. I am getting date in 01/01/2015 00:23:00 format as input. I am reading it as a string in tfileinput.. I need to convert in talend in the format YYYY-MM-DD HH24:MI 0683p000009M9p6.pngS and output it to my table.
please let me know how we can do this. Its throwing error when i am trying to use TalendDate.parseDate("yyyy-MM-dd HH:mm:ss","store_date") in tmap.
Thanks
Anonymous
Not applicable
Author

Hi,
I have a input like "1-Jan-54" in string format. I want to convert it date format("dd-mmm-yy").
Anonymous
Not applicable
Author

Hi shrish2092,
Have you tried to use method TalendDate.parseDate() in tMap?
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi xdshi,
Yes, i tried this is the function TalendDate.parseDate("DD-MMM-YY",row1.DOB) I gave. But I am not getting proper output.
For example, 
My Input
"1-Jan-54"   12/27/1953
"30-Dec-54" 12/27/1953
"1-Jan-41" 12/29/1940
"1-Jan-45" 12/31/1944
"14-May-43" 12/27/1942
"15-Jul-69"  12/29/1968
Anonymous
Not applicable
Author

Hi xdshi,
Yes, i tried this is the function TalendDate.parseDate("DD-MMM-YY",row1.DOB) I gave. But I am not getting proper output.
I want same output as input but in date format.
For example, 
My Input      Output I am getting
"1-Jan-54"    12/27/1953
"1-Jan-41"    12/29/1940
"14-May-43" 12/27/1942
"15-Jul-69"   12/29/1968
For each month it is taking as DECEMBER, and for year it is decreasing by 1. DD is also not correct.
Anonymous
Not applicable
Author

Try this code:
Date dNow = new Date("1-Jan-54");
SimpleDateFormat dateFormat = new SimpleDateFormat("mm/MM/yyyy");
String  currdate = dateFormat.format(dNow);
System.out.println(currdate);
My output is 01/01/1954
Or if you want to use your current code, replace the capital "M"s and "Y"s with "m" and "y", and give it a try.
Anonymous
Not applicable
Author

Hi jummilsso,
Replacing the capital "M"s and "Y"s is not working, giving an error.
I am new to this tool so can you plz help me with above logic implementation through mapping.
Anonymous
Not applicable
Author

Try this one line of code for your mapping then:
new SimpleDateFormat("dd/MM/yyyy").format(new Date(row1.DOB))
Anonymous
Not applicable
Author

Hello for me I add the local and it work 
TalendDate.parseDateLocale("EEE MMM d HH:mm:ss zzz yyyy", "Sun Mar 06 11:28:16 IST 2011","en") 
Anonymous
Not applicable
Author

Hi Team,
Need your input on this.
Database : oracle 12c
Talend : v6.1 DI enterprise version
We have a table A which contains LAST_RUN_DATE column with TIMESTAMP datetype. Need to insert data for this column would be as below like
current_date+ "00:30:00" i,e I need to concatenate current date with timestamp(hardcoded value) as shown.  We are using tFixedFlowinput to populate the LAST_RUN_DATE column value and expression given is
TalendDate.formatDate("dd/MMM/yyyy HH:mm:ss",TalendDate.parseDate("dd-mm-yyyy HH:mm:ss",context.To_Date).
 Here context.To_Date variable datatype is STRING and same for To_DateTime.
context.To_DateTime ="00:30:00";
context.To_Date= TalendDate.getDate("dd-MM-yyyy")+' '+context.To_DateTime;
We are not able to insert the value in the above format specified.seems like formatting issue. Could you help us with the format to get the desired output.
Expected value to be inserted  for today for example should be  LAST_RUN_DATE:  31-MAY-16 00:30:00:000 
The date format in oracle DB for LAST_RUN_DATE column in Table A is  31-MAY-16 14.02.43.000000000. 
Thanks,
Sanjay