I am trying to compare two dates to each other
How I am doing this is:
//To get the actual DATE
def today = new Date().format('yyyy-MM-dd hh:mm:ss')
//To define the Done DATE and TIME
def done = issue.get("fixVersions").startDate.toString()
if ((today) < (done)) {
true
}
else{false}
This technically works to compare the dates, but if I want to add time to the FixVersion start date, I need to convert the string to a date object. I have tried to do that by changing the code to:
//To define the done DATE and TIME
def done = issue.get("fixVersions").startDate.toString()
def doneDate = new Date().parse("yyyy-MM-dd hh:mm:ss", done)
However, this fails with the following error:
java.text.ParseException: Unparseable date: "[2021-02-28 00:00:00.0]"
Any idea what I'm doing wrong here?
Hi @Steve Beauchamp , I think "fix versions" is Collection of values (https://docs.atlassian.com/software/jira/docs/api/8.12.0/com/atlassian/jira/issue/Issue.html#getFixVersions--), so what groovy does is:
So you probably need something like, because startDate is of Date type (https://docs.atlassian.com/software/jira/docs/api/8.12.0/com/atlassian/jira/project/version/Version.html#getStartDate--):
Thanks! This worked perfectly. I just had to modify it slightly to compare the date + 16h to 'today'.
The final code I used was:
//To get the actual DATE
def today = new Date().format('yyyy-MM-dd hh:mm:ss')
//To define the Done DATE and TIME
def doneDate = issue.getFixVersions().get(0)?.startDate.format('yyyy-MM-dd')+" 16:00:00"
if ((today) < (doneDate)) {
true
}
else{false}
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.
At the American Academy of Family Physicians, siloed marketing teams faced delays and duplicate work. Kerrie Gottschalk shook things up by moving the department to Jira, streamlining processes, boosting visibility, and sparking stronger collaboration.
Read the story
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.