No Signature for toTimestamp Error

    Problem

    You are developing a synchronization between 2 instances one of which is Jira on-premise.

    Error detail:
    No signature of method: java.util.Date.toTimestamp() is applicable for argument types: () values: [] 

    Cause

    Since the recent Groovy engine upgrade, there are issues with existing connections in Exalate for Jira on-premise 5.1.0 using the .toTimestamp function.

    Solution

    The new java.sql.Timestamp (date.time) function is now preferred to be in use. 

    Check out the following example of the method (function):

    def dateCustomFieldValue(replicaCustomField) {
        def datePattern = "yyyy-MM-dd'T'HH:mm:ssZ"; // 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.getTime());
        }
    }