Scriptrunner error on time duration/counter Scripted Field

Hi, how can I resolve the following?

running JIRA 6.4.7 and Scriptrunner 4.1.3.5

 

import com.atlassian.core.util.DateUtils
def resolvedNames = ["Resolved", "Closed"]
def timeDiff;
if (issue.statusObject.name in resolvedNames) {
    timeDiff = issue.getResolutionDate().getTime() - issue.getCreated().getTime()
} else {
    timeDiff = System.currentTimeMillis() - issue.getCreated().getTime()
}
DateUtils.getDurationString(Math.round(timeDiff / 1000))

 

Error -

 

image2015-12-10 12:5:49.png

 

1 answer

1 accepted

0 vote

You can probably just do a cast there:

DateUtils.getDurationString(Math.round((timeDiff / 1000) as Double))

Not exactly sure what's going on, but it's obviously having trouble inferring the type for "timeDiff / 1000".

It's safe to ignore the type checking information... https://scriptrunner.adaptavist.com/latest/jira/#_static_type_checking

Thanks Jamie. That worked a treat!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Asked 13 hours ago in Confluence

What are the resources that you use to learn more about Atlassian Products?

I am gathering information about resources available for Atlassian product knowledge transferring for a presentation in our local Atlassian User Group. I want to group them in four categories From ...

63 views 3 4
View question

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