Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting an object from a List with the condition

jiradev February 27, 2018

Hello,

How from List<Issue> issues = new ArrayList<Issue> get one issue which has maximum date value for example?
  Thanks in advance.

1 answer

1 vote
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2018

You need to sort your list like this:

import com.atlassian.jira.issue.Issue

List<Issue> issues = new ArrayList<>();

if(issues.size() == 0)
return

issues.sort(new Comparator<Issue>() {
@Override
int compare(Issue o1, Issue o2) {
return o1.getDueDate().after(o2.getDueDate()) ? -1 : 1
}
})

return issues.get(0)
jiradev February 28, 2018

Thanks!)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events