Export Date not Timestamp when exporting using RPE
I have fields in RQM where I am assigning a Date to a Test Case and when I export to RPE I want to display only the date - preferably in a UK style format dd/mm/yyyy.
However in RPE it always displays the a timestamp as well as the date in us format yy/mm/dd.
Is there a way to change this without having to use Java Script to parse and split the string up before re-assembling with just the informaiton I am interested in exporting.
However in RPE it always displays the a timestamp as well as the date in us format yy/mm/dd.
Is there a way to change this without having to use Java Script to parse and split the string up before re-assembling with just the informaiton I am interested in exporting.
One answer
If you are printing the date (dateTime) in a Text element, set Date pattern (in Properties->Specific tab for the Text element) property.
As an alternate, you can use a JavaScript function to change the date format. These functions can be readily found in .js files under %rpe_home%\utils\scripts, if you are using RPE 2.1 or later. Here is a sample function:
//function to change date format to "MMM dd, yyyy"
function changeDateFormat(date)
{
try
{
var currDtFmt = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
var curDt = currDtFmt.parse(date);
var expDtFmt = new java.text.SimpleDateFormat("MMM dd, yyyy");
var dateString = expDtFmt.format(curDt).toString()
_sessionLogger.info("##### data string: " + dateString);
return dateString;
}
catch(err)
{
java.lang.System.out.print( err);
return date;
}
}
As an alternate, you can use a JavaScript function to change the date format. These functions can be readily found in .js files under %rpe_home%\utils\scripts, if you are using RPE 2.1 or later. Here is a sample function:
//function to change date format to "MMM dd, yyyy"
function changeDateFormat(date)
{
try
{
var currDtFmt = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
var curDt = currDtFmt.parse(date);
var expDtFmt = new java.text.SimpleDateFormat("MMM dd, yyyy");
var dateString = expDtFmt.format(curDt).toString()
_sessionLogger.info("##### data string: " + dateString);
return dateString;
}
catch(err)
{
java.lang.System.out.print( err);
return date;
}
}
Comments
Propoerties changes doesn't work. (I suspect because I have to grab the value, assign it to a variable and then print the variable.)
I'm working with RPE 1.3 - and there's nothing in the utils folder. Is there somewhere else I can find these javascript functions?
I ran a quick test and just setting Date format to yyyy-MM-dd works fine.
However, setting it to yyyy-MM-dd returned incorrect date.