Hi Get your date with TalendDate.parse() then in a tMap, output two columns : TalendDate.format("yyyy-MM-dd", row.myDate) TalendDate.format("hh:mm:ss", row.myDate)
You can also use the Talend native date tool with which you can select the format of your date (in the schema, when you select Date as the type of your column, you can set the pattern of your date. Use "yyyy-MM-dd hh:mm:ss" in the input flow and use "yyyy-MM-dd" in the output date flow and "hh:mm:ss" in the output time flow)
I am using tJavaRow and performing this on my input string "2009-02-20 02:04:36" dt=TalendDate.parseDate("yyyy-mm-dd HH:mm:ss",date); dt=TalendDate.parseDate("MM-dd-yyyy",TalendDate.formatDate("MM-dd-yyyy", dt)); ti=TalendDate.parseDate("hh:mm:ss",TalendDate.formatDate("hh:mm:ss", dt)); but i m getting result as 20-01-2009|01-01-1970 which is totally wrong. I can only use tJavaRow as I m doing lot more thing in it.
You're doing it wrong. You have a Date Object which contains all of your information "2009-02-20 02:04:36 +GMT blablabla" You have an input string "2009-02-20 02:04:36". You convert it into a date object (with the parseDate) or natively in Talend when you choose "Date" as your column type. Then you can output the same date object in the format you want : "MM-dd-yyyy" will output your date object as "02-20-2009" "HH:mm:ss" will output your date object as "02:04:36" But you could also output your date as : "MM/dd@ss+mm_dd" that would output your date object as "02/20@36+04_20" (that's just a fantasy example) You just have ONE date object and TWO (or more) outputs.
The Date Patterns only affect file input or output (or tLogRow) because they are effectively display masks and do not change the underlying field value. That is why the full date value is being sent to MySQL. If you send the results to DATE and TIME fields in MySQL rather than DATETIME fields, the extraneous part should just be ignored.
Because that is not a valid date, you will not be able to read it from the file as a date without causing an error and thus the row to reject. You will need to use a tReplace to change the String "01/0001" to a null and then a tConvertType to change the (cleaned) Strings to a Date before writing to your output.