Pb with date

One Star

Pb with date

Hello,
I want to initialize a context value with the current date minus one month. (This context velue is then send to a child job)
I'm a beginner under JAVA so I try in a tJavaFlex the code :
Calendar cal = Calendar.getInstance();
context.setProperty("sdhm",routines.TalendDate.formatDate("yyyyMM",Cal.add (Cal.MONTH, -1)));

There's compilation errors :
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Calendar cannot be resolved to a type
Calendar cannot be resolved
Cal cannot be resolved
Cal cannot be resolved
at testoracle7.jobmaitre.jobmaitre.tJavaFlex_1Process(jobmaitre.java:141)
at testoracle7.jobmaitre.jobmaitre.runJob(jobmaitre.java:297)
at testoracle7.jobmaitre.jobmaitre.main(jobmaitre.java:244)
I try then to include this line :
import java.util.Calendar;
but new errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "import", assert expected
java.util.Calendar cannot be resolved
Calendar cannot be resolved to a type
Calendar cannot be resolved
Cal cannot be resolved
Cal cannot be resolved
at testoracle7.jobmaitre.jobmaitre.tJavaFlex_1Process(jobmaitre.java:142)
at testoracle7.jobmaitre.jobmaitre.runJob(jobmaitre.java:304)
at testoracle7.jobmaitre.jobmaitre.main(jobmaitre.java:248)
Could you help me please
Gilles
Community Manager

Re: Pb with date

Hi
Calendar cal = Calendar.getInstance();

Write these code in a routine, then, call this routine in tJavaFlex component.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Employee

Re: Pb with date

You can also use the tContextLoad component.
Regards,
One Star

Re: Pb with date

Hello MHONG and MHIRT,
thanks very much for your help : It's OK

Best regards
Gilles