Example:
Days = 3d
Creation date = 17/06/2020
Due date = 22/06/2020 (exclude non working days )
Can you elaborate on what context we're looking at here? Is it for a post-function? Which one?
I am trying it using script runner
@Shivi Gupta try to use this code:
LocalDate result = createdDate; <br>int addedDays = 0<br><span>int days = 3</span><br>while (addedDays < days) {<br> result = result.plusDays(1); if (!(result.getDayOfWeek() == DayOfWeek.SATURDAY || result.getDayOfWeek() == DayOfWeek.SUNDAY)) {<br> ++addedDays;<br> }<br> } <br>Timestamp dueDate = Timestamp.valueOf(result.atStartOfDay());<br>issue.setDuedate(dueDate)import java.sql.Timestamp<br>import java.time.LocalDate<br>import java.time.ZoneId<br><br>Timestamp created = isssue.getCreated()<br>LocalDate createdDate = created.toInstant().atZone(<strong>ZoneId.systemDefault()</strong>).toLocalDate()<br>
LocalDate result = createdDate;
<br>
int
addedDays =
0
<br><span>int days = 3</span><br>
while
(addedDays < days) {
<br>
result = result.plusDays(
1
);
if
(!(result.getDayOfWeek() == DayOfWeek.SATURDAY || result.getDayOfWeek() == DayOfWeek.SUNDAY)) {
<br>
++addedDays;
}<br>
}
<br>Timestamp dueDate =
Timestamp.valueOf(result.atStartOfDay());<br>issue.setDuedate(dueDate)
@Martin Bayer _MoroSystems_ s_r_o__
This code is throwing errors :
@Shivi Gupta I tried to fix the code, give it a try, please
Try something like this (+8 Hours in my case):
def date = new Date();Calendar calendar = Calendar.getInstance();date=calendar.getTime();calendar.add(Calendar.HOUR_OF_DAY, 8)if(calendar.get(Calendar.DAY_OF_WEEK)==7){calendar.add(Calendar.DAY_OF_MONTH, 2)}if(calendar.get(Calendar.DAY_OF_WEEK)==1){calendar.add(Calendar.DAY_OF_MONTH, 1)}date=calendar.getTime();
It looks like you're new here. Sign in or register to get started.