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,560,349
Community Members
 
Community Events
185
Community Groups

Set due date the timestamp class gives error

I'm currently working on script where I choose a customfield value and the due date will be set automatically

I get an error on the "Timestamp dueDateTimestamp = new Timestamp(myDueDate.getTimeInMillis())"  unable to resolve class timestamp.

What do I do wrong, what am I missing

 


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

// get value of valid period custom field
// LOGIC around what date is due date
// CALCULATION of due date
// INPUT the due date

def VALIDPERIOD = 10206 as Long

// def issue
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey('MEG-24')
def dateToSet

//Get Managers
def CustomFieldManager = ComponentAccessor.getCustomFieldManager()


//Get Custom field Value
def ValidPeriodCustomField = CustomFieldManager.getCustomFieldObject(VALIDPERIOD)
def validPeriodValue = issue.getCustomFieldValue(ValidPeriodCustomField)

log.warn(validPeriodValue)

//Logic around what date
if (validPeriodValue == '30 Days') {
dateToSet = 30

}

else if (validPeriodValue == '60 Days') {
dateToSet = 60
}

else {
dateToSet = 90
}

log.warn('Date to set: ' + dateToSet + ' Line 40')

Calendar myDueDate = Calendar.getInstance()
myDueDate.add(Calendar.Date, dateToSet)

Timestamp dueDateTimestamp = new Timestamp(myDueDate.getTimeInMillis())

//input the calculated due date
issue.setDueDate(dueDateTimestamp)

log.warn ('New due date is: ' + dueDateTimestamp)

1 answer

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 30, 2021

I don't think you need to worry about timestamp and calendar classes.

Just use the built-in java dates. 

def dueDate = new Date()+dateToSet
def dueDateTimestamp = dueDate.toTimestamp()

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events