Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How convert time to string in Eclipse BIRT

Hello!
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!

0 votes


Accepted answer

Permanent link
Hi Dmitry, I will try to answer your question but unfortunately you are not going to like the response. There is a limitation in the BIRT version we are using that makes it impossible to expose the LONG type. In your case you are trying to use two features that we do not fully support:
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?
Dmitry A. Lesin selected this answer as the correct answer

0 votes

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

Permanent link
The qm:executionelementresult is a XML dateTime data format.  You can use javax.xml.datatype.XMLGregorianCalendar.toXMLFormat() to create a XML dateTime.

0 votes

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,


The starttime property should already be in the XML dateTime format.  Are you suggesting it isn't.  Can you check the output from the RQM Reportable REST API?

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 Dmitry,

The negative startTime does not seem right.   

Try this for the conversion:

public long dateTime = ...
public static final String RFC_3339_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
private static SimpleDateFormat rfc3339DateFormat = new SimpleDateFormat(RFC_3339_DATE_PATTERN, Locale.ENGLISH); 
rfc3339DateFormat.setTimeZone(TimeZone.getTimeZone("GMT_ID"));
rfc3339DateFormat.format(dateTime)

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,


As I mentioned, the negative starteTime values are suspect.  As Rafik mentioned:

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. 

showing 5 of 9 show 4 more comments

Permanent link
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!

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,023
× 7,499
× 324
× 13

Question asked: May 23 '16, 2:02 a.m.

Question was seen: 8,051 times

Last updated: Jul 17 '16, 9:03 p.m.

Confirmation Cancel Confirm