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! |
Accepted answer
2 other answers
Paul Slauenwhite (8.4k●1●2)
| 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,
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.
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,
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,
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.
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
|
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
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.