One Star

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?
4 REPLIES
Four Stars

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");
?
One Star

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.
Four Stars

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());
One Star

Re: set context to current date?

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