You are not logged in.
I haven't found any post mentioning this, and I have no idea where the problem is.
I am using a tChronometerStart and tChronometerStop in my job to get the start time and execution time of the job, and i am trying to access those values from a tJava component but I am always getting null values even though the tChronometerStop is displaying correctly the result on the console.
I have attached a picture of my simple job. As you can see on the console, the values in the Java code are null, but the tChronometerStop is displaying correctly the result.
The code in my tJava_1 component is the following:
System.out.println("Duration : " + ((String)globalMap.get("tChronometerStop_1_DURATION"))); System.out.println("Start Time : " + ((String)globalMap.get("tChronometerStart_1_STARTTIME")));
Does anyone know where the problem is and how to access those values from a Java component?
Thank you in advance.
OS: Windows XP
Talend version: TIS 3.2.2r33000
Generated language: Java
Yes, the two global vars are not avaliable now, you can report a bug on our bugtracker.
For now, you can extract those values on tJava like this:
long startTime=(Long)globalMap.get("tChronometerStart_1"); java.util.Calendar c=java.util.Calendar.getInstance(); c.setTimeInMillis(startTime); java.util.Date date=c.getTime(); System.out.println("Start Time : " +TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",date)); System.out.println("Duration : " +(((Long)globalMap.get("tChronometerStop_1"))-((Long)globalMap.get("tChronometerStart_1")))+"milliseconds");
Start Time : 2010-01-28 11:00:17 Duration : 125milliseconds
Thanks Shong for your answer. For now I'll stick to the workaround.
This issue has been reported as a bug (id 11390) on the bugtracker.
Link to the bug: http://www.talendforge.org/bugs/view.php?id=11390
Other related report at [Bugtracker, bug 10978, fixed] tChronometerStop: You can't retrieve the duration.
For using last components, it can be download from:
TOS Trunk component directory
After updates for this two components, input code likes:
System.out.println(new Date((Long)globalMap.get("tChronometerStart_1_STARTTIME"))); System.out.println((Long)globalMap.get("tChronometerStop_1_DURATION"));
I want to write the duration n start time into a file,
how can I do that?
right now, i'm thinking like having 2 context variables liek duration n start_time
which will be assigned values using tJava during run time,
but I don't know how to write into a file.
Hi I got the duration working in a job a while ago