The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA 5.2: How to format milliseconds in hh:mm:ss

Rumit Patel
July 25, 2013

I have a scripted filed using which I want to show the Turn Around Time (TAT) on the Issue Navigator.

So far, following is the formula I am using to get the TAT in miliseconds.

(issue.resolutionDate != null) ? String.format("%d milisecs",(int)((issue.resolutionDate.getTime() - issue.getCreated().getTime()))) : "N/A" ;

Is there any way to convert these milliseconds back to 'hh:mm:ss' format in JIRA?

Regards,

Rumit

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Rumit Patel
July 25, 2013

Found the answer!!!

import java.util.concurrent.TimeUnit;

int TATmili = (int)((issue.resolutionDate.getTime() - issue.getCreated().getTime())) ;

String TATFormated = String.format("%02d:%02d:%02d", 

    TimeUnit.MILLISECONDS.toHours(TATmili),

    TimeUnit.MILLISECONDS.toMinutes(TATmili) - 

    TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(TATmili)),

    TimeUnit.MILLISECONDS.toSeconds(TATmili) - 

    TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(TATmili)));