I am trying to set created to current date using below method in my script,but it is throwing error "cannot find matching method com.atlassian.jira.issue.MutableIssue#setCreated(long)"
newIssue.setCreated(System.currentTimeMillis())
Any one can help me on what is wrong here
Hi,
That's because the setCreated() method needs a TimeStamp to set the new created date.
If you want to set created date to "currentTimeInMillis" you could try with something like this:
import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
import java.sql.Timestamp
import java.util.Date
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def createdDate = new Date(System.currentTimeMillis())
def df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
def dt = df.format(createdDate)
def date = df.parse(dt)
def ts = new Timestamp(date.getTime())
//note that "issue" is the issue you want to set the created date.
//In your case may be newIssue as I can see in the code you've pasted.
issue.setCreated(ts)
issue.store()
Best Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vineela Durbha ,
Looking at the error message and at the api, setCreated method is expecting a timestamp object, try
import java.sql.Timestamp
newIssue.setCreated(new Timestamp(System.currentTimeMillis()))
instead.
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.