When I synchronize 2 field Date Picker synchronizes with one day less

Good afternoon ,

I have a connection from project A in a cloud instance and project B in another data center version instance. I need to synchronize the value of a field called ETA. The fields are Date Picker type.

but when it comes to synchronizing the fields, it is synchronized in project B one day before what was placed. Does anyone know how I can solve this with the Date Picker type field?

hi @Andrey_Miranda

The same scenario was discussed and you can follow it here:

Let me know if you found the shared information helpful.

BR,
Jillani

Hello @Jillani_Fazal

Before sending the query I read the post but according to what is in the post they did not solve the issue.

I found something similar in a post with the Due date field, I tried to change the code to this one but it doesn’t work, do you know if the case can be solved at the code level?

Hi @Andrey_Miranda

Thank you for the update. Will be working with you on the ticket which I have just updated.

Appreciated.

BR,
Jillani

Hi @Andrey_Miranda, As mentioned on the ticket, here is the script for other to use in case of having the same issue

Outgoing script

replica.customFields.“DatePicker” = issue.customFields.“DatePicker”

Incoming script

import java.text.SimpleDateFormat

if (replica.customFields.“DatePicker”) {
def dateValue = replica.customFields.“DatePicker”.value // Extract actual date

if (dateValue) {
    // Remove time part if present (keep only YYYY-MM-DD)
    def cleanedDate = dateValue.toString().split(" ")[0]

    // Parse as LocalDate
    def parsedDate = java.time.LocalDate.parse(cleanedDate)

    // Add 1 day
    def adjustedDate = parsedDate.plusDays(1)

    // Convert to Java Date object (required for Jira fields)
    def sdf = new SimpleDateFormat("yyyy-MM-dd")
    def finalDate = sdf.parse(adjustedDate.toString()) // Convert to Date object

    // Assign the corrected Date object back to Jira
    issue.customFields."DatePicker".value = finalDate
}

}

In case of needing to Subtract 1 day
def adjustedDate = parsedDate.plusDays(1)
to
def adjustedDate = parsedDate.minusDays(1)

BR
Tomas Lalanne

1 Like