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
Eight 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

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now