Behavior script to compare three date fields

Hi I have three date fields and I would like to compare them.
There is some issue with conversion and it is not working as expected.
Can you help me on this

1 answer

0 vote

You'll need to explain what you are trying to do and what you've got so far.

I was trying to compare two date time custom fields using behavior as below.


import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.config.ConstantsManager
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import java.text.SimpleDateFormat
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import org.joda.time.format.DateTimeFormatter
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

FormField GAField = getFieldByName("Planned General Availability Date")
FormField RCdate = getFieldByName("Planned RC Date")

FormField cl=getFieldByName("Change List #")

String dateGA=GAField.getValue()
String dateRC=RCdate.getValue()


Date newDate1=Date.parse("E MMM dd HH:mm:ss 'CDT' YYYY",dateGA)
Date newDate2=Date.parse("E MMM dd HH:mm:ss 'CDT' YYYY",dateRC)

GAField.setError("GA date should be greater tha RC date")
else if(newDate1.after(newDate2))

 But the comparision is not working. I think when i change time it is not working.
Can you check this and let me know if any error in this

Suggest an answer

Log in or Join to answer
Community showcase
Alexey Matveev
Published Saturday in Jira

How to run Jira in a docker container

Everything below is tested on Ubuntu 17.10. I prefer to use Jira in a docker container because: 1. I can install Jira with a couple of commands. 2. I can start and stop Jira just by starting and s...

95 views 2 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot