It's all about the answers!

Ask a question

How convert time to string in Eclipse BIRT


Dmitry A. Lesin (24826996) | asked May 23 '16, 2:02 a.m.
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!

Accepted answer


permanent link
Rafik Jaouani (5.0k16) | answered Jun 28 '16, 2:10 p.m.
JAZZ DEVELOPER
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

Comments
Dmitry A. Lesin commented Jun 29 '16, 2:31 p.m. | edited Jun 29 '16, 2:34 p.m.

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
Paul Slauenwhite (8.4k12) | answered May 24 '16, 10:28 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited May 30 '16, 9:42 a.m.
The qm:executionelementresult is a XML dateTime data format.  You can use javax.xml.datatype.XMLGregorianCalendar.toXMLFormat() to create a XML dateTime.

Comments
Dmitry A. Lesin commented May 26 '16, 4:09 p.m.

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!


Paul Slauenwhite commented May 30 '16, 9:50 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

 See javax.xml.bind.DatatypeConverter.parseDateTime(String).


Dmitry A. Lesin commented Jun 24 '16, 12:23 a.m.

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.


Paul Slauenwhite commented Jun 28 '16, 12:45 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

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?


Dmitry A. Lesin commented Jun 29 '16, 2:18 p.m.

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!


Paul Slauenwhite commented Jun 30 '16, 7:06 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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)

Dmitry A. Lesin commented Jul 15 '16, 12:09 p.m.

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!


Dmitry A. Lesin commented Jul 15 '16, 12:16 p.m.

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.


Paul Slauenwhite commented Jul 17 '16, 9:03 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

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
Dmitry A. Lesin (24826996) | answered Jun 29 '16, 2:15 p.m.
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!

Your answer


Register or 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.