Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,990
Community Members
 
Community Events
184
Community Groups

need to write the script in the postfunction to add the current date + 10 Days excluding the weekend

need to write the script in the postfunction of the workflow  to add the current date + 10 Days excluding the weekend

Please help me in exclude the weekends

eg : current date = 9th nov 4:12 +10 days  means the result should show as 

result = 23 nov 4:12 ( as weekend will fall on saturday and sunday)

 

Already written the script which is adding 10 days but including the weekends:

import com.atlassian.jira.component.ComponentAccessor

import java.sql.Timestamp

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def dateCf = customFieldManager.getCustomFieldObject("customfield_18761") issue.setCustomFieldValue(dateCf, new Timestamp((new Date() + 7).time))

return dateCf

 

2 comments

Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 11, 2020

Hi @kiranmai genkolla,

I've written custom listener similar to your requirement quite long back(it's for 5 days)

this may give you some idea for start point

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.core.util.DateUtils
import java.util.Date.*
import java.text.SimpleDateFormat;
import java.text.DateFormat;

Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def baselineName = customFieldManager.getCustomFieldObjectByName("Base Date Field")
def baselineValue = issue.getCustomFieldValue(baselineName) as Date
DateFormat df = new SimpleDateFormat("dd/MMM/yyyy");

if(baselineValue != null)
{

Calendar baselineDate = GregorianCalendar.getInstance();
baselineDate.setTime(baselineValue);
int nod = 5
int weeks = (nod/5).intValue();
int remDays = nod%5;
baselineDate.add(Calendar.WEEK_OF_YEAR, weeks);

for(int i=1;i<=remDays;i++){
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
}

if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);


baselineDate.clearTime()

//c1.getTime()
return baselineDate.getTime()
}
else {}

 

BR,

Leo

Like Alexander Bondarev likes this

Comment

Log in or Sign up to comment