how to get the week number from the date time picker customfield in jira to use in behavior script?

rakesh rocckz July 24, 2019

in Jira issue I want my customers to select the dates in the date time picker  custom field only for next week so I want to hide the days of this week or I want to get the week number of the date what  they have selected and I will compare with the current week number and if both week numbers match then it means that they have selected this week so I want to show a text field why they have selected this week to enter the reason why they have selected this week or if the selected week is greater than the current week then the text field should be hidden.

 

In the behaviors, I want to write in groovy to get the week number from the date what they have selected in the date-time picker. I want to get the week number from the date what they have selected in the calendar custom field in groovy behavior script what they selected in the calendar custom field and I will compare with the current week number then based on that I want to show or hide the text field. please help me how to get the week number from date time picker custom field in groovy behavior script from the date what they have selected? please help me out 

1 answer

0 votes
brbojorque
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 1, 2019

Hi @rakesh rocckz ,

Please review this sample snippet.

def startDate = getFieldByName("Start date").getValue()
date = new SimpleDateFormat('yyyyMMdd').parse(startDate.format('yyyyMMdd'));

Calendar cal = Calendar.getInstance()
cal.setTime(date)
log.debug(cal.get(Calendar.WEEK_OF_YEAR))

Suggest an answer

Log in or Sign up to answer