hi
I want show first worklog date (base on start date, not create date) in a date field.
this is my code that use worklog list and get first element of list. but this is base on work log created date, not base on worklog start date.
WorklogManager worklogManager = ComponentAccessor.getWorklogManager()
List<Worklog> worklogList = worklogManager.getByIssue(issue)
Worklog firstWorklog = worklogList[0]
return firstWorklog.getStartDate()
this code return start date of first created worklog but I want to show start date of first worklog base on start date. in other words I need a worklog list that sort base on worklog start date but worklogManager.getByIssue(issue) return a worklog list that sort base on worklog create date.
any help for this ?!
thanks
thank for your help
must I import any thing for these functions ?!
ok, I solved problem with this code :
WorklogManager worklogManager = ComponentAccessor.getWorklogManager()
List<Worklog> worklogsList = worklogManager.getByIssue(issue)
Worklog firstWorklog
for (item in worklogsList){
if (firstWorklog == null){
firstWorklog == item
}
if (item.getStartDate().getTime() < firstWorklog.getStartDate().getTime()){
firstWorklog = item
}
}
return firstWorklog.getStartDate()
The code has an error with == instead of =.
Here you are the correct code:
WorklogManager worklogManager = ComponentAccessor.getWorklogManager()
List<Worklog> worklogsList = worklogManager.getByIssue(issue)
Worklog firstWorklog
for (item in worklogsList){
if (firstWorklog == null){
firstWorklog = item
}
if (item.getStartDate().getTime() < firstWorklog.getStartDate().getTime()){
firstWorklog = item
}
}
return firstWorklog.getStartDate()