I have a created a scripted field which calculates the amount of hours between two dates that are recorded in two other custom fields. Now I am being asked to display the time in " XX D xx H xx M but I can not figure out how to do that. I have also been asked if it is possible to have this calculation exclude weekends. Is this at all possible? Please help!
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import java.util.Date.*
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObject('customfield_15968');
def dateFieldObject2= customFieldManager.getCustomFieldObject('customfield_15967');
if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2)) {
def dateValue = issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2 = issue.getCustomFieldValue(dateFieldObject2) as Date
def calculation = (dateValue.getTime() - dateValue2.getTime()) / 3600000
return (calculation as String)
}