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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

270 views 2 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you