Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Serpico
Contributor
Contributor

[resolved] tChronometerStart and tChronometerStop return null durations

Hi,
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.
System:
OS: Windows XP
Talend version: TIS 3.2.2r33000
Generated language: Java
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hello
Yes, the two global vars are not avaliable now, you can report a bug on our bugtracker.
((String)globalMap.get("tChronometerStop_1_DURATION"))
((String)globalMap.get("tChronometerStart_1_STARTTIME"))
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");

output result:
Start Time : 2010-01-28 11:00:17
Duration : 125milliseconds

Best regards
shong

View solution in original post

7 Replies
Serpico
Contributor
Contributor
Author

Hi,
Could it be a bug? Was anyone able to extract those values?
Anonymous
Not applicable

Hello
Yes, the two global vars are not avaliable now, you can report a bug on our bugtracker.
((String)globalMap.get("tChronometerStop_1_DURATION"))
((String)globalMap.get("tChronometerStart_1_STARTTIME"))
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");

output result:
Start Time : 2010-01-28 11:00:17
Duration : 125milliseconds

Best regards
shong
Serpico
Contributor
Contributor
Author

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: https://community.talend.com/t5/Design-and-Development/parse-date-from-string/td-p/66056
Thanks.
Anonymous
Not applicable

Hi,
Other related report at 10978.
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"));

Regards.
Anonymous
Not applicable

Hi,
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.
Please advice.
Anonymous
Not applicable

Hi I got the duration working in a job a while ago
See post
https://community.talend.com/t5/Design-and-Development/tChronometerStop-Readable-Time/td-p/87555
Regards
Brandon
alevy
Specialist
Specialist

Use tFixedFlowInput to create a row(s) containing your output and link it to tFileOutputDelimited