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

How to extract time tracking fields using JIRA/GreenHopper API?

Matt Becker July 25, 2012

Hello,

I am making a plugin that needs to extract the time tracking fields (Original Estimate, Remaining Estimate, and Time Spent) of an Issue. I am currently trying to use the methods listed here: http://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/Issue.html#getEstimate%28%29

I have an Issue object that I am calling getEstimate() on, which returns a long which should be the estiamte time in milliseconds, however the values it is returning is incorrect (it seems to be off by a factor of 10000 milliseconds). I am not sure what is going on here, is this the correct way to get the time tracking fields from an Issue? Also does anyone know if in JIRA if you set the time estimate to be something like 3 weeks, does that mean 3 workings weeks (120 hours) or 3 total weeks (504 hours)?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Jobin Kuruvilla [Adaptavist]
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.
July 25, 2012

Hours in a week depends on what you configured in the time tracking settings.

https://confluence.atlassian.com/display/JIRA/Configuring+Time+Tracking

And yes, getting time using those APIs is the right way to do it. I don't remember if it was miliseconds or seconds but the API says ms.

Matt Becker July 25, 2012

My settings are set up for 8 working hours a day, 5 working days in a week. When I extract the estimate from an Issue and convert the milliseconds to hours and minutes some the data is off. For example I have an issue in which the original estimate is 3 weeks (120 hours) however the value I keep getting is 120. This only seems to be happening for time values over 1 week. Any idea of what is happening here? Here is my code for converting the time:

long time = mi.getOriginalEstimate().longValue(); 
String minutes = Integer.toString((int)((time % 3600) / 60)); 
String hours = Integer.toString((int)(time / 3600));

Jobin Kuruvilla [Adaptavist]
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.
July 25, 2012

oh yeah, that's right. You need to add them up!

Tony Filipe October 17, 2013

Although the API Javadoc says that Issue.getEstimate() and Issue.getOriginalEstimate() return milliseconds they actually return seconds.

0 votes
Matt Becker July 25, 2012

I just realized it is because the Issue class methods to get the estimates do not count the values for the subtasks. Is there a way for that to be easily included without having to manually get each Issue's list of subtasks, calculate their estimate times, and add them back to the main task?

TAGS
AUG Leaders

Atlassian Community Events