put the current date into a postgresql timestamp column

One Star

put the current date into a postgresql timestamp column

Hi,
I'm new with talend and can't find a solution for the following simple problem:
I want to write the current date to a postgressql column with type "timestamp without timezone" using the components tMap and tPostgreSQL.
I tried TalendDate.getDate("CCYY-MM-DD hh:mm:ss") the talend format is Date with dateformat "yyyy-MM-dd' 'HH:mm:ss"
If I try to run the job it complains Talend can't convert String to Date
If I change Date to String, the job starts but cannot write the data to the database I get the errormessage "ERROR: column »datum_anlage« has type timestamp without time zone, but the expression has Typ character.
Has anybody an idea how to solve this problem?
Thanks!
anna.talend

Re: put the current date into a postgresql timestamp column

Open Studio doesn't shield you from the underlying Java language very much at all. Java is strongly typed, and you'll come across this type of thing again and again as you get familiar with Talend.
So, since what you're writing to is a Date, you have to send a java Date object. And the schema has to be set to Date. You can create a java date with the java expression "new Date()", or if that doesn't work "new java.util.Date()". That will be the current time.
So, instead of "TalendDate.getDate()", try "new java.util.Date()" and let us know if that gives a different error message (sorry it's not convenient for me to create a new job and table to test it out but I think that'll work).
Levin
One Star

Re: put the current date into a postgresql timestamp column

Hi Levin,
thanks, a lot!
I tried java.util.Date and java.sql.Timestamp both works.
anna.talend
Seven Stars

Re: put the current date into a postgresql timestamp column

Hi,
The question is very old,but when am trying to do the same am unable to get the out put
am using tmap and tmysql output
and only one column date and in tmap date column  expression i am using "new java.util.Date()".but it is not displaying nor inserting date column into table
tmap---->tmysqloutput
regards,
rekha