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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

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 votes

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
com.atlassian.jira.issue.issuetype.IssueType
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()

cl.setFormValue(dateGA)

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)

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

 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 Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

641 views 7 23
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