Question

I am currently using the Rally Test Case Result creation code created by NickM (Located at https://raw.githubusercontent.com/nmusaelian-rally/rally-java-rest-apps/master/addTCRtoTC.java). My question is concerning the date.

newTestCaseResult.addProperty("Date", "2014-04-09T18:00:00.000Z");

Is there a way to update the Java code to have it automatically select the current date/time (that the script was run) rather then having a fixed value there? Thanks in advance.

Was it helpful?

Solution

There are different ways to do it in java. You need a current date/time and iso format. This is one way:

You may import:

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

and then:

Date d = new Date();
DateFormat iso = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");

newTestCaseResult.addProperty("Date", iso.format(d));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top