4 answers
- 210
Jira sent unix Time stamp 1613484000000 to ServiceNow.
ServiceNow converted it to 16th Feb 3 AM instead to 16th Feb 3PM.When ServiceNow sends time stamp to Jira, it shows correct time.
We see time difference of 12 Hours in ServiceNow.
Method used for above test:
import java.text.SimpleDateFormat
def timestamp = (replica.customFields."Reported Date"?.value) //millisecondsdefsdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
def targetDate
if (replica.customFields."Reported Date"?.value)
{
targetDate = sdf.format(replica.customFields."Reported Date"?.value)
incident.u_reported_date_time = targetDate
}
After some tests and checks here (https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) it appeared that we need to have Capital "H" for Hours to reflect the 24 Hours Format.
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
Add your comment... - 10-1
I apologize for the simplistic question, but how did this work in the incoming and outgoing scripts?
Add your comment... - 10-1
The issue was solved by changing the simple Date format to "yyyy-MM-yy HH:mm:ss"
The capital "H" was required as ServiceNow setting is 24 hours format, and not 12 hours format.
Add your comment... - 10-1
Hi Andrew
The string needs to be converted to date
Always a good testbed to try out groovy scripts is
https://groovyconsole.appspot.com/
Check out following codeUntestedimport java.text.SimpleDateFormat def sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") Date date = sdf.parse("2020-12-03 13:43:48") print "Date = ${date}"
Results inAdd your comment...
Hello,
I've got an error as below:
"Cannot cast object '2020-12-03 13:43:48' with class 'java.lang.String' to class 'java.util.Date' "
It appeared after I added to SN outoging sync rule line:
SN incoming sync rule line looks as below:
In SN field
u_reported_date_time
is a date/time type.