We had issues where only some of the questions weren't appearing in some of our spaces. We attempted to complete a UI driven rebuild of the content index, and that failed due to an OOM received. It was decided to adjust our heap and rebuild from scratch our content index. Now we can only see ~15 questions overall. We see there are questions that have been asked, and the only way to view those old ones, is if there is a direct link reference elsewhere in a page.
Should we restore our index directory or question directory at this point? Is there another index we should complete?
This seems to get the job done. Found at https://stackoverflow.com/questions/18354727/how-to-calculate-number-of-days-between-two-dates-excluding-weekend-java and added necessary imports. You could take this and make a function out of it.
import java.text.DateFormat;
import java.text.SimpleDateFormat;
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date date1 = df.parse("01/05/2019");
Date date2 = df.parse("31/05/2019");
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal2.setTime(date2);
int numberOfDays = 0;
while (cal1.before(cal2)) {
if ((Calendar.SATURDAY != cal1.get(Calendar.DAY_OF_WEEK))
&&(Calendar.SUNDAY != cal1.get(Calendar.DAY_OF_WEEK))) {
numberOfDays++;
}
cal1.add(Calendar.DATE,1);
}
System.out.println(numberOfDays);
Payne,
This solved the problem perfectly. Thank you for your help. For anyone who is attempting to achieve the same result in their Jira instance, here is how I modified the above information to work in the workflows:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.user.util.UserManager;
import com.atlassian.jira.issue.MutableIssue
import java.util.Date.*
import java.text.DateFormat;
import java.text.SimpleDateFormat;
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
def createdDate = issue.getCreated()
log.warn("Date Created: " + createdDate)
def dueDate = issue.getDueDate()
log.warn("Due Date: " + dueDate)
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(createdDate);
cal2.setTime(dueDate);
def numberOfDays = 0;
while (cal1.before(cal2)) {
if ((Calendar.SATURDAY != cal1.get(Calendar.DAY_OF_WEEK)) && (Calendar.SUNDAY != cal1.get(Calendar.DAY_OF_WEEK))) {
numberOfDays++;
}
cal1.add(Calendar.DATE,1);
}
log.warn("Number of Days Between Dates: " + numberOfDays)
issue.setOriginalEstimate(numberOfDays * 8 * 60 * 60); //Set Original Estimate to number of days between Due Date and Created Date
issue.setEstimate(numberOfDays * 8 * 60 * 60); //Set Remaining Estimate to number of days between Due Date and Created Date
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I want to use the similar query as below for SQL, can you please help here?
I am trying to display duration column with difference between 2 dates (From Date and To Date) in Confluence. I have tried below:
select *,(CAST(ROUND(ceiling(DATEDIFF(DAY,'From Date','To Date')))as int))+1+ " days" as 'Duration' from T1
this gives the result, however given the dates 25-Jun-2020 to 26-Jun-2020 - duration displayed as 1 instead of 2.
your help is appreciated here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.