converting to unix timestamp for mysql

One Star

converting to unix timestamp for mysql

in a tmap i have to convert something like "02.08.08" into a unix timestamp to store it in a mysql database. can anybody give me a hint how to do that? i am quite new to java.
many thanks...
Community Manager

Re: converting to unix timestamp for mysql

Hello
Set the data type as String for this column, then parse a string to a date.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: converting to unix timestamp for mysql

thanks but it does not give the right result:
i have :
02.08.2008 (string)
and i need to store:
1217635200 (long)
this is the result of:
long epoch = new java.text.SimpleDateFormat ("dd/MM/yyyy HH:mm:ss").parse("01/01/1970 01:00:00");
but i cannot use this expression in tmap as expression
any idea?
regards
....
Community Manager

Re: converting to unix timestamp for mysql

Hello
On tMap, try
(TalendDate.parseDate("dd.MM.yyyy",row1.date)).getTime()

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business