Monday, March 14, 2016

How to Convert Remedy Time to UTC TimeStamp

This question came up on the INUG-USERS mailing list the other day, and our own IV Blankenship was the person who came to the rescue:

Question:
Using Impact WebService we capture the Ticket Close time from Remedy.

I observer Remedy sends the datetime in the below format. How to convert
the below format to NetCool UTC datetime format and display in NetCool
Dashboard.

*2016-02-23T20:45:09-08:00 -> with timezone embedded*



Answer:
The Impact ParseDate function is a wrapper for the Java SimpleDateFormat
class (
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html)

The problem with your date string is the timezone. SDF and ParseDate by
extension expect it to be (+-)NNNN not (+/-)NN:NN.
Also, you have to escape the T using single quotes.


You did not say if you were using IPL or Javascript, but here is some IPL
that will work and verify that your data is in the expected format.

d="2016-02-23T20:45:09-08:00";
if(d like '(\d\d\d\d\-\d\d\-\d\dT\d\d:\d\d:\d\d)([\+\-]\d\d):(\d\d)$') {
  parts=RExtractAll(d,
'(\d\d\d\d\-\d\d\-\d\dT\d\d:\d\d:\d\d)([\+\-]\d\d):(\d\d)$');
  tempDateString=parts[0]+parts[1]+parts[2];
  Log(0,tempDateString);
  f="yyyy-MM-dd'T'HH:mm:ssZ";
  pd=ParseDate(tempDateString, f, null);
  Log(pd);
}
else {
  Log(0,"Unsupported date format!");
}