I've installed Jira Misc plugin. And I'd like to calculate date field, based on another custom fields.
I've created Number calculated field (Customfield_12695) to calculate number of days between two date fields:
<!-- @@Formula: // Date1 - issue.get("customfield_11295") // Date2 - issue.get("customfield_10151") (issue.get("customfield_11295") == null || issue.get("customfield_10151") == null ? null : (issue.get("customfield_11295").getTime() - issue.get("customfield_10151").getTime()) / 1000 / 3600 / 24) -->
It works well.
Next I've tryed to create Date-time calculated field for calculate date based on values from created Customfield_12695 and two another custom date fields:
<!-- @@Formula: (issue.get("customfield_11295") == null || issue.get("customfield_10151") == null || issue.get("customfield_11493") == null ? null : org.apache.commons.lang.time.DateUtils.addDays(issue.get("customfield_11493"), issue.get("customfield_12695").IntValue())) -->
It doesn't work. I don't understand why...
I also tryed to create formula without another calculated custom field, but it's not working, becouse I can't pass integer argument for addDays(date, integer) function...
<!-- @@Formula: (issue.get("customfield_11493") == null || issue.get("customfield_10151") == null || issue.get("customfield_11295") == null ? null : org.apache.commons.lang.time.DateUtils.addDays(issue.get("customfield_11493"), (issue.get("customfield_11295").GetTime() - issue.get("customfield_10151").GetTime()) / 1000 / 3600 / 24 ))
-->
If I change expression (issue.get("customfield_11295").GetTime() -issue.get("customfield_10151").GetTime()) / 1000 / 3600 / 24 ) in this formula to integer number - it works.
Help me please to create correct formula for my use case.
I've tryed this variant from another Question, but it doesn't work too:
<!-- @@Formula:long days(Date start, Date end) { Calendar c1 = GregorianCalendar.getInstance(); c1.setTime(start); int w1 = c1.get(Calendar.DAY_OF_WEEK); c1.add(Calendar.DAY_OF_WEEK, -w1 + 1); Calendar c2 = GregorianCalendar.getInstance(); c2.setTime(end); int w2 = c2.get(Calendar.DAY_OF_WEEK); c2.add(Calendar.DAY_OF_WEEK, -w2 + 1); //end Saturday to start Saturday long days = (c2.getTimeInMillis()-c1.getTimeInMillis())/(1000*60*60*24); if (w1 == Calendar.SUNDAY) { w1 = Calendar.MONDAY; } if (w2 == Calendar.SUNDAY) { w2 = Calendar.MONDAY; } return days-w1+w2; } // Plan date of finish development - customfield_11493 // Plan date of publication for customer - customfield_11492 // Date of agreement estimation time by cusomer - customfield_11295 // Date of customers notification - customfield_10151 if (issue.get("customfield_11493")==null || issue.get("customfield_10151") == null || issue.get("customfield_11295") == null) return null; return org.apache.commons.lang.time.DateUtils.addDays (issue.get("customfield_11493"), days(issue.get("customfield_11295"), issue.get("customfield_10151"))) -->
But it doesn't work too :(.
I've decided my problem described hear. There was problem in type of second argument of addDays() function. Decision is use intValue() in expression when calulated number of days for second argument.
This constuction is working now:
<!-- @@Formula:(issue.get("customfield_11493") == null ? null : org.apache.commons.lang.time.DateUtils.addDays(issue.get("customfield_11493"), ((issue.get("customfield_11295").getTime()-issue.get("customfield_10151").getTime())/(1000*60*60*24)).intValue()))
-->
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.