Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to set the display format in a behavior script on dd-mm-yyyy


I want to copy the value of a Custom field Date picker on a Jira Service Management portal via a Behavior from an issue selected in an issue picker field.

The copy action works, but it is not displayed in the desired format.

How do I make sure it is displayed in the format dd-mm-yyyy?


Regards, Marco


current script:


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager

def issueManager = ComponentAccessor.getIssueManager() as IssueManager
def issuePickerCustomFieldValue = getFieldById(getFieldChanged()).value
def relatedIssue = issueManager.getIssueByCurrentKey(issuePickerCustomFieldValue as String)
def EinddatumprojectCustomField = getFieldByName("Einddatum project")
def EinddatumprojectCustomFieldObject = customFieldManager.getCustomFieldObjectsByName("Einddatum project")[0]
def EinddatumprojectCustomFieldValue = (EinddatumprojectCustomFieldObject ? relatedIssue.getCustomFieldValue(EinddatumprojectCustomFieldObject) : null) as String
if (EinddatumprojectCustomFieldValue) {


2 answers

1 accepted

1 vote
Answer accepted

When you retrieve the value from your custom field, don't coerce the type to String:

def EinddatumprojectCustomFieldValue = (EinddatumprojectCustomFieldObject ? relatedIssue.getCustomFieldValue(EinddatumprojectCustomFieldObject) : null) as String

Because when you do that, you get the default format and you can't change it.

Instead, keep it as a Timestamp  (the default data type for date in jira) so you can use the format method (with optional user timezone)

def EinddatumprojectCustomFieldValue = (EinddatumprojectCustomFieldObject ? relatedIssue.getCustomFieldValue(EinddatumprojectCustomFieldObject) : null) as java.sql.Timestamp
if (EinddatumprojectCustomFieldValue) {

//to format date based on user tz instead of server tz
//def userTimeZone = ComponentAccessor.getComponent(com.atlassian.jira.timezone.TimeZoneManager).loggedInUserTimeZone
//EinddatumprojectCustomField.setFormValue(EinddatumprojectCustomFieldValue.format('dd-MM-yyyy',userTimeZone ))

@Peter-Dave Sheehan Thanks!  It works!

2 votes
Nir Haimov Community Leader Aug 17, 2021

Hi @Marco Brundel 

When you set the date to your field , try to do it like this:


Suggest an answer

Log in or Sign up to answer

Atlassian Community Events