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

Scriptrunner: show time in status in hours

Hi Community!

I have created a custom field through scriptrunner, which shows the time an issue have been in the status "Under Review". 

The field is created with the Duration template and is scripted as follows:


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

def inProgressName = "Under Review"

List<Long> rt = [0L]
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "status")
changeItems.reverse().each { ChangeItemBean item ->
def timeDiff = System.currentTimeMillis() - item.created.getTime()
if (item.fromString == inProgressName) {
rt << -timeDiff
if (item.toString == inProgressName) {
rt << timeDiff

def total = rt.sum() as Long
return (total / 1000) as long ?: 0L


Currently the field displays the time in status with Weeks, Days, Hours and Minutes.
What i need, is for it to display the total time in hours only.

From looking around here in the community, I can see that i might have to import:

But, I am unsure of how i change the actual output shown in the field, so it's only showing the total amount of hours.

Any help or hints are greatly appreciated.

1 answer

You can access JiraDurationUtils using following code.



This class converts seconds to user readable strings but as far as I can remember it counts each day as 8 hours, and each week as 5 day depending on Jira settings. So 28800 seconds (8 hours) may be displayed as 1day.

Hi Deniz, 

Thanks for you reply! 

I need days to be counted as 24 hours, due to how the team works in the project. 
along with that, 24 hours shouldn't be shown as "1 day" but instead 24 hours.

What i'm looking to do, is simply show the total amount of hours an issue have been in a certain status. 

Do you know how this would be done?

Suggest an answer

Log in or Sign up to answer

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