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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using ScriptRunner Post Function to set issue End Date to endOfMonth

 Hi, I´m trying to set up a post function script where the Enddate will be set to the end of the current month.


The actual script considers the currentdate value +30days.

Has anyone got an idea to change the +30 to endOfMonth?


import com.atlassian.jira.component.ComponentAccessor

import java.sql.Date

import java.sql.Timestamp

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.issue.CustomFieldManager

import com.atlassian.jira.issue.fields.CustomField

import org.apache.log4j.Logger

import org.apache.log4j.Level


// Manager

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()



CustomField currentDate = customFieldManager.getCustomFieldObject("customfield_11808")

Timestamp currentDateValue = (Timestamp)issue.getCustomFieldValue(currentDate)



Date newDateValue = new Date(currentDateValue.getTime())


//Add 1 month

newDateValue.setMonth(currentDateValue.getMonth() +1)


//Update custom field

issue.setCustomFieldValue(currentDate, newDateValue.toTimestamp())

1 answer

Hello @Jörg Friedmann,

You can use the following code to get end of the month. Just modify to parameters according to your currentDateValue variable.

 GregorianCalendar calendar = new GregorianCalendar(2018, 8, 0);
Date date = calendar.getTime();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

// dateFormat.format(date) returns the last day of the month

Hi Thanks a lot but I´m running on an error

2018-09-14 10_12_21-Update Workflow Function Parameters.png

Can ypu please explain what you mean with currentDateValue vaiable?

I changed the date format to dd-MM-yy also but without success

If you want to set all dates to the current month's last day, you don't need use currentDateValue. I missunderstood, forget what I said:) 

By the way did you import the date libraries?

I guess not. 

I tried some modifcations but failed, Im not able to adapt your code to mine.

ALso what I do not understand is how your code interacts with the condition to set the new date of the issue to 1month in future.


Maybe my explanation was bad. Background is I have a workflow where every issue set to done will be cloned to a new issue. This new issue shall have the end date value changed 1month forward automatically.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

3,998 views 11 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