How to Sync Date and DateTime Custom Fields in Jira On-premise

    This article shows how to synchronize Date/DateTime custom fields.

    Jira Cloud and Jira on-premise use different data types to store the value of the Date custom field. If you're exchanging the custom field value between different issue-tracking platforms you need to transform the value into the proper type on the receiving side. Below you can find an example of a simple date custom field synchronization that works for syncing custom fields. 

    Source Side

    Jira Outgoing sync(Data Filter)

    To send the data use the code below:

    replica.customFields."My Date CF" = issue.customFields."My Date CF"

    Destination Side

    Jira Incoming sync(Create/Change processors)

    issue.customFields."My Date CF".value = replica.customFields."My Date CF".value

    Note: If you synchronize the date custom field between Jira Cloud and Jira on-premise you need to transform the formatted date to the proper value type. 

    The example below shows how you can transform the received value to the timeStamp format on Jira on-premise. 

    Jira On-premise 

    Incoming sync(Create/Change processors)

    // ======= Date CF ===============
    import java.text.SimpleDateFormat;
    import java.text.DateFormat;
    def dateCustomFieldValue(replicaCustomField) {
        def datePattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; // define the desired date/time format
        String dateString = replicaCustomField.value;
        if (dateString) {
            dateString = dateString.replaceAll("\"","").trim();
            DateFormat formatter = new SimpleDateFormat(datePattern);
            date = formatter.parse(dateString);
            return new java.sql.Timestamp(date.time);
    issue.customFields."My Date CF".value = dateCustomFieldValue(replica.customFields."My Date CF");
    // ======= Date CF ===============