How to transfer the date time field value into the text field in Jira

Hi Team,

I want to transfer the date time field value into the text field,

Please advice me how can I achieve this.

3 answers

0 votes

Hi Najmul,

do you need to do that in a transition? if so, you can setup a scripted post function for that purpose.

Let me know.



Hi Fabio,

What are the code that I have to write into the Post function. How can I copy the value from date field to simple text field.

Please suggest your answer on the same.

Many thanks in advance!



0 votes

Hello Najmul,

here your post-function script code :

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
import java.text.SimpleDateFormat;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.event.type.EventDispatchOption;

SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
IssueManager issueManager = ComponentAccessor.getIssueManager();
Issue issue  = issue;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField dateField = customFieldManager.getCustomFieldObjectByName("Date Field");
CustomField textField = customFieldManager.getCustomFieldObjectByName("Text Field");
    Date val = (Date)issue.getCustomFieldValue(dateField);
    MutableIssue mIssue = (MutableIssue) issue;
    mIssue.setCustomFieldValue(textField, sdf.format(val));
    issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), mIssue, EventDispatchOption.DO_NOT_DISPATCH, false);

Please, update Fields Name and date format at your convenience.

Hope this helps,


Hi Fabio,

Its worked fantastically!

but with a problem, Its showing the time which is entering in the database means Singapore time. I want to show the time which is currently in the date field same in the text field.

Please give your valuble answer!



please could you provide me the desired format?

Hi Fabio,

After creating the ticket the date time field showing me the time as per Indian time zone. As per my knowledge, In database it storing in the form of Singapore time zone.

So when I am trying to run your code it give me the date which is present in the database.

My requirement is that, The date should be come in Inian time zone in the text field.

If you need any more clarification then et me know.

Hi Najmul,

at database level a date is stored as a date (universal) and not as specific timezone. You can define the presentation date format editing the date format into JIRA System Administration panel.

What we need to fix your issue is the desidered date format for your text field :

example yyyy/DD/mm , mm/DD/yyyy, mm-DD-yyyy and so on.

Hope this clarifies,


Please, could you mark this answer as accepted if your question has been resolved?

Hi Fabio,

Sorry for the late reply, I was on leave.

The code which is provided by you, I just added this code into the post function in the step of create and it is successful. But the same field value is getting chage into the next step, So when I put the same code into the next step post function I am getting the error in log "1 of 2 custom field is already in used"

can you please help me on this!



Thanks for your help Fabio,

I got the solution for the same.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,773 views 18 21
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you