Note

We've packed up and moved from Confluence to Discourse to bring you a better, more interactive space. Out of courtesy we didn't migrate your user account so - you will have to signup again

The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

If your Jira and ADO are hosted in different time zones, and you need to manipulate the date/time fields so that the same date is kept, here is how we do it. Let us assume:

  • "Due Date" and "Start Date" are custom date/time fields in ADO
  • "Start date" is a custom Date field in Jira
  • Due is the standard due date field in Jira
  • We would like to add 5 hours to the Jira timestamp when they are received in ADO
  • We would like to subtract 3 hours to the ADO timestamp when they are received in Jira (just as an example)


Jira Outgoing Script
replica.customFields."Start date" = issue.customFields."Start date"
replica.due = issue.due


Jira Incoming Script
import java.text.SimpleDateFormat
import java.text.DateFormat
import java.util.Calendar
import java.util.Date

def datePattern = "yyyy-MM-dd HH:mm:ss";
DateFormat formatter = new SimpleDateFormat(datePattern);
dateString = replica."start"
dateString = dateString.replaceAll("T"," ").trim();
dateString = dateString.replaceAll("Z"," ").trim();  
date = formatter.parse(dateString);
def timestamp = date.time
Calendar calendar = Calendar.getInstance()
calendar.timeInMillis = timestamp
calendar.add(Calendar.HOUR_OF_DAY, -5)
def updatedTimestamp = calendar.timeInMillis
issue.customFields."Start date".value = updatedTimestamp

dateString = replica."duedate"
dateString = dateString.replaceAll("T"," ").trim();
dateString = dateString.replaceAll("Z"," ").trim();  
date = formatter.parse(dateString);
timestamp = date.time
calendar.timeInMillis = timestamp
calendar.add(Calendar.HOUR_OF_DAY, -5)
issue.due = calendar.getTime()
ADO Outgoing Script
replica."start" = workItem."Microsoft.VSTS.Scheduling.StartDate"
replica."duedate" = workItem."Microsoft.VSTS.Scheduling.DueDate"
Jira Outgoing Script
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date

def convertJiraTimeToAdoTime(String dateString){
    if(dateString == null) return 
    String inputFormat = "yyyy-MM-dd HH:mm:ss.S"
    String outputFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"

    // Create SimpleDateFormat objects for the input and output formats
    SimpleDateFormat inputDateFormat = new SimpleDateFormat(inputFormat)
    SimpleDateFormat outputDateFormat = new SimpleDateFormat(outputFormat)

    // Parse the input date string into a Date object
    Date date = inputDateFormat.parse(dateString)

    def timestamp = date.time
    Calendar calendar = Calendar.getInstance()
    calendar.timeInMillis = timestamp
    calendar.add(Calendar.HOUR_OF_DAY, 5)
    def updatedTimestamp = calendar.timeInMillis

    // Convert the Date object into the output format
    return outputDateFormat.format(updatedTimestamp) // String
}

// does not set the field
String inputDateString = replica.customFields."Start date"?.value 
workItem."Microsoft.VSTS.Scheduling.StartDate" = convertJiraTimeToAdoTime(inputDateString)
inputDateString = replica.due 
workItem."Microsoft.VSTS.Scheduling.DueDate" = convertJiraTimeToAdoTime(inputDateString)