How convert time to string in Eclipse BIRT
I work with BIRT report for Rational Quality Manager. Extracting data from "com.ibm.rqm.execution.ExecutionElementResult" table (live schema), I need to use starttime field. But I can not convert the data to suitable form of presentation.
I created a computed field for that with function:
function() {
importPackage(Packages.java.text);
var sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm", reportContext.getLocale());
var mydate = sdf.format(row["startTime"]);
return mydate;
}
But the result is blank:
Can somebody help me with converting the time date into a readable format?
Thank you very much in advance!
Accepted answer
1) We do not support users creating their own QM BIRT reports.
2) Your BIRT report is using the generic BIRT schema that exposes the raw internal repository data.
Internally the execution result start time is stored using a long and since BIRT can only expose INTEGERs and not LONGs, I do not think you are going to be able to proceed any further.
Have you tried using the LIVE_EXEC_RESULT table from the PLANNING_SNAPSHOT schema?
Comments
Hi Rafik, Thank you for connecting to this conversation! The innitial task which was required by customer is such. They want to monitor the activities of testers. Another word, they want monitor the users sessions in RQM. For example, the want get quickly a signal if some of testers have taken a pause (for example paused for two hours) in running the existing tests.
I didn't find other variants (including the tables in planning shapshot) to get the use case described above. I found the table "com.ibm.rqm.execution.ExecutionElementResult" only, where the information about each passed step is saved, and there is start and end time info. This table could be an excelent solution if I could use starttime field!
In my mind, I can use almost any Java commands in computed fields. And if I could know about starttime format, I could give the required business value to customer.
Thank you in advance for any help!
2 other answers
Comments
Hi Paul,
Thank you for your advice but it seems, I came to a standstill! I can not understand which the type is starttime in RQM. For example, if starttime = 2075907740 and the type of this value is TIMESTAMP then starttime points to 2035 year (but correct year must be 2016).
I tried many variants in last three days but I can not get current year in the result.
Could you please clarify your answer, how I could convert starttime to XMLGregorianCalendar? Or may be, could you give me some more information about correct type of starttime in the "com.ibm.rqm.execution.ExecutionElementResult" table of RQM?
Thank you very much in advance!
See javax.xml.bind.DatatypeConverter.parseDateTime(String).
Sorry, but the question still remains - how convert initial Integer value (type of the original startTime field) into String to apply it in ...parseDateTime(String)? As I believe, this transformation is application specific.
Hi Dmitry,
Hi Paul,
I'm sorry if I do something wrong. But I have done next.
I run a TCER where one of steps was set in "Deferred" state. I checked start time which is about June 29, 2016, 21:05 (may be distinctive in about a few hours if time zone isn't correct).
In the BIRT model, I have starttime field of type Integer (table "com.ibm.rqm.execution.ExecutionElementResult"):
When I preview the table data, I see:
startTime = -1658912921
I created a computed field "start2" with next code:
if(row["startTime"] != 0) {
cal = javax.xml.bind.DatatypeConverter.parseDateTime(row["startTime"]);
df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
df.format(cal.getTime());
}
else "";
I have a result:
start2 = 94715163-02-19 19:17:34.848 MSK
As you can see the year 94715163 is in far far future!
Hi Paul,
Our administrators were working with testing environment for some reason, and it was recreated from scratch. Now I can work with it again.
I reproduced your recommendation with some modifications for JavaScript:
dateTime = row["startTime"];
RFC_3339_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
rfc3339DateFormat = new java.text.SimpleDateFormat(RFC_3339_DATE_PATTERN, java.util.Locale.ENGLISH);
rfc3339DateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT_ID"));
rfc3339DateFormat.format(dateTime);
The result is in start3 field of screenshot:
I'd like to say that the the time value is very near to the real value. I fixed the real datetime that was "2016-07-15 18:35...". But I can not say the same about YYYY-MM-dd part! This is very far from the real value.
I see a strange negative value in startTime too but it was created by Jazz v4.0.7 itself :(
Thank you!
And in addition to mentioned above. Apperantly, the time is really right because the blocked step was passed first in the list of steps of a test script.
Hi Dmirty,
I'm sorry if I do something wrong. But I have done next.
I run a TCER where one of steps was set in "Deferred" state. I checked start time which is about June 29, 2016, 21:05 (may be distinctive in about a few hours if time zone isn't correct).
In the BIRT model, I have starttime field of type Integer (table "com.ibm.rqm.execution.ExecutionElementResult"):
When I preview the table data, I see:
startTime = -1658912921
I created a computed field "start2" with next code:
if(row["startTime"] != 0) {
cal = javax.xml.bind.DatatypeConverter.parseDateTime(row["startTime"]);
df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
df.format(cal.getTime());
}
else "";
I have a result:
start2 = 94715163-02-19 19:17:34.848 MSK
As you can see the year 94715163 is in far far future!