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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
talendtester
Creator III
Creator III

Talend reformating database date fields

When I exported the results of a SQL query (against an Oracle database) to a flat file, I noticed Talend is changing the format for date fields.
SqlPlus output format (Format I would like the output to be):
20-MAR-09 06.20.00.000000 PM
Talend:
Fri Mar 20 18:20:00 MST 2009
I am using a tMap object and auto mapping the fields.
I tried the following for to go from a date to a date:
Attempt 1:
TalendDate.setDate(row2.CREATE_DATE, 01, "dd-MMM-yy HH:mm:ss.SSSS")
Attempt 2:
TalendDate.formatDate("dd-MMM-yy HH:mm:ss.SSSS", row2.CREATE_DATE)
Attempt 3:
TalendDate.formatDate("day MMM dd HH:mm:ss yyyy", TalendDate.parseDate("dd-MMM-yy HH.mm.ss.SSSS PM",row2.CREATE_DATE));

Error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method parseDate(String, String) in the type TalendDate is not applicable for the arguments (String, Date)
at myjob.tOracleInput_4Process(myjob.java:8776)
at myjob.runJobInTOS(myjob.java:11133)
at myjob.main(myjob.java:11049)
Job myjob ended at 16:02 14/09/2009.
Labels (4)
3 Replies
Anonymous
Not applicable

Hello
The method parseDate(String, String) parse a string a Date.
The method formatDate(String, Date) format a Date to a string.
In you case, row2.CREATE_DATE is a Date, and you want to format it to string with a pattern.
So, you could use the following method to format a Date a string:
TalendDate.formatDate("dd-MMM-yy HH:mm:ss.SSS aa", row2.CREATE_DATE)
Best regards
shong
talendtester
Creator III
Creator III
Author

The following works when I change the Output type to String and leave the Input type to Date
TalendDate.formatDate("dd-MMM-yy HH.mm.ss.SSSSSS aa",row2.CREATE_DATE);
Why would Talend auto mapping change the formatting of date fields?
Anonymous
Not applicable

Hello
Why would Talend auto mapping change the formatting of date fields?

The input type is a Date, so Talend print it with the locale default format. If you want to see it in one pattern, you need format it as you do above.
Best regards
shong