Format date returned by getReleaseDate()

Venkat Krishnamoorthy February 1, 2017

Hello,

I have the following behaviour script that on a create screen, based on "FixVersion" selection, autopopulate "Prod Date" field with selected FixVersion's Release Date. The script works in a way it does pull the release date and auto populate the "Prod Date" field. But I would like date to be formatted in default JIRA format (e.g. 15/Feb/17).

Any assistance here would be much appreciated.

 

----------------------------------------------------

import com.atlassian.jira.project.version.Version

def fixVersions = getFieldById(getFieldChanged())
def Proddate = getFieldByName("Prod Date")

Collection<Version> fixVersionsValue = (Collection<Version>) fixVersions.getValue()

def reldate = fixVersionsValue.releaseDate

Proddate.setFormValue(reldate)

 

Thanks.

3 answers

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2017
reldate.format("dd/MMM/yy")
Venkat Krishnamoorthy February 2, 2017

Hi Jamie,

The date formatting isnt working for me. Please see screenshot.

 

date format.jpg

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2017

Because you've got a collection of Version objects. Do you want the release date from the first, the last, or what?

for the first you could use:

fixVersionsValue.first().releaseDate.format(...)

Venkat Krishnamoorthy February 3, 2017

Thanks Jamie, that worked.

Venkat Krishnamoorthy February 3, 2017

Jamie,

Could you also help troubleshoot the Rest endpoint https://answers.atlassian.com/questions/44598650

I am trying to achieve the following - In the same JIRA instance, I would like to pull Issues from one JIRA project to another and display the list as a select pulldown list.

With limited background in this, I am having trouble understanding why I dont see any Issues when I invoke the endpoint from the browser.

 

Thanks!

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2017

Does that have anything to do with this question?

Venkat Krishnamoorthy February 3, 2017

No, it does not. I provided the link to the other thread, hoping you could help me there.

0 votes
Venkat Krishnamoorthy February 2, 2017

Thanks for responding, Vasiliy.

Its a date field.

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 1, 2017

What type ProdDate is? Is it a text or date field?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events