import com.atlassian.jira.component.ComponentAccessor import java.text.SimpleDateFormat import java.time.LocalDate; import java.time.temporal.ChronoUnit; // 实际提交UAT时间(字段ID 10016) def actualUatField = ComponentAccessor.customFieldManager.getCustomFieldObject(10016L) def plannedUatField = ComponentAccessor.customFieldManager.getCustomFieldObject(10015L) // 预计提交UAT时间(字段ID 10015) Date actualValue = issue.getCustomFieldValue(actualUatField) as Date Date plannedValue = issue.getCustomFieldValue(plannedUatField) as Date // 空值校验 if (!actualValue || !plannedValue) { return '实际提交UAT时间或者预计提交UAT时间为空,不能计算,请补全信息' } LocalDate actualDate = LocalDate.parse(new SimpleDateFormat('yyyy-MM-dd').format(actualValue)); LocalDate plannedDate = LocalDate.parse(new SimpleDateFormat('yyyy-MM-dd').format(plannedValue)); long diffDays = Math.abs(ChronoUnit.DAYS.between(actualDate, plannedDate)); long diffDays = ChronoUnit.DAYS.between(actualDate, plannedDate); return diffDays;
Overview
Content Tools