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

Date format in transition (script runner)

Hi community,

I try to put due date in date field during transition. I use this script :

// On récupère la valeur dans le champ date Livré Réal
def champDateLivre = getFieldById( "customfield_10400" )

// On crée un objet date
def dateDuJour = new Date();

// On crée la date du jour
dateDuJour = dateDuJour.format( "d/MMM/yy" );

// On récupère la valeur du champ date livré
def valeurInitiale = getFieldById( "customfield_10400" ).value

// Si la date n'est pas alimentée
if ( valeurInitiale == "" )

// On l'alimente avec la valeur de date du jour

My résult is : 3/Jul/19 but I've got an error that say wrong format. Use d/MMM/yy

But is it.

When I pick the date manualy in calendar, I've got 3/Juil./19

How can I synchronize it ? Exemple force french calendar... or other

1 answer

1 accepted

0 votes
Answer accepted

You can get the datepicker format of the current date based on the current user's language using the following:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.datetime.DateTimeFormatterFactory
import com.atlassian.jira.datetime.DateTimeStyle

def formatterFactory = ComponentAccessor.getComponent(DateTimeFormatterFactory.class)
def localDatePicker = formatterFactory.formatter().forLoggedInUser().withStyle(DateTimeStyle.DATE_PICKER)
localDatePicker.format(new Date())

Thanks for your answer, but it doesn't work. Does it mean that my user have an other language compare to my systeme ?

You'll need to provide more details if you want help.

Are you getting errors/stack traces? 

What date string is inputted in your date field?


This was just an example of how to get the date in the user's format. Try it in the scriptrunner console. 

To apply to your code, you will need to do something like

champDateLivre.setFormValue(localDatePicker.format(new Date()))

I missed the good application.

It's wonderfull, it's work !

Thank you very much Peter-Dave

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

192 views 0 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you