I need to have Incident End default to now as I close a ticket. Since I can't use Default value, I'm using a Jira Behaviour instead.
This script works EXCEPT the date/time is off by 12 hours when the timezone is not the same as the default time zone. If it's 5 PM in the US Central tz and 11 PM in the UK, the UK user closing a ticket has the Incident End set to 11 AM instead of 11 PM. It works correctly for a user in the US Central tz. What am I doing wrong?
@BaseScript FieldBehaviours fieldBehaviours
def dateField = getFieldByName("Incident End")
def timeZoneManager = ComponentAccessor.getComponent(TimeZoneManager)
def loggedUserZoneId = timeZoneManager.loggedInUserTimeZone.toZoneId()
DateFormat formatter = new SimpleDateFormat("dd/MMM/yy h:mm a")
def newLocalDateTime = LocalDateTime.now()
def newDate = Date.from(newLocalDateTime.atZone(loggedUserZoneId).toInstant())
dateField.setFormValue(formatter.format(newDate))