You are not logged in.

#1 2010-02-05 21:04:14

tnewman
Member
194 posts

set context to current date?

Hi

I am trying to set a string context variable to the current date

context.setProperty("run_date", TalendDate.getDate("YYYY-mm-dd"));
System.out.println( context.run_date);

but I get nothing returned?

Help?


------------------
Talend Version - TIS 4.1.2
Generated Code - Java
OS - WinXP SP3 / Linux

Offline

#2 2010-02-05 21:22:43

jkrfs
Member
204 posts

Re: set context to current date?

why not

context.run_date = TalendDate.getDate("YYYY-mm-dd");

?

or even

context.run_date.equals(TalendDate.getDate("YYYY-mm-dd");

?

Offline

#3 2010-02-05 21:28:22

tnewman
Member
194 posts

Re: set context to current date?

Hi,

Nope.

I am trying to set it in a tJava component at the start of the job. I have read other post and it says to use the setproperty function I just can't get it to work.

Thanks in advance for help.


------------------
Talend Version - TIS 4.1.2
Generated Code - Java
OS - WinXP SP3 / Linux

Offline

#4 2010-02-05 22:26:46

jkrfs
Member
204 posts

Re: set context to current date?

Hi,

Yep.

I have multiple jobs right now that I set the current date in the tJava component at the beginning of the flow so that I can use it in later parts of the job.

Have you tried the method I suggested? Because like I said, it works for me.

Infact, I think if you want to format the date it has to be this way:

context.run_date = TalendDate.formatDate("yyyy-MM-dd",TalendDate.getCurrentDate());

Last edited by jkrfs (2010-02-05 22:28:42)

Offline

#5 2010-02-06 01:29:10

tnewman
Member
194 posts

Re: set context to current date?

Hi,

Thanks that works - Must be a bad Friday for me.


------------------
Talend Version - TIS 4.1.2
Generated Code - Java
OS - WinXP SP3 / Linux

Offline

Board footer

Talend Contributor Agreement - Talend Website Privacy Policy