It's all about the answers!

Ask a question

How to list all the workitem based on Creation Date?


Prabhashree Poojary (131) | asked Aug 26 '21, 8:12 a.m.
I want to list all the work items created between 19.08.2021 to 21.08.2021.

Code Snippet
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = null;
Date endDate = null;
                 try {
                        startDate = dateFormat.parse("2021-08-20 00:00:00");
                        endDate = dateFormat.parse("2021-08-22 00:00:00");
                        } catch (Exception e) {
                        e.printStackTrace();
                     }
                     Timestamp startTime = new Timestamp(startDate.getTime());
                     Timestamp endTime = new Timestamp(endDate.getTime());   
                       
 //Query to filter the work item
                IAuditableClient auditableClient = (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
                IQueryableAttribute typeAttibute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.TYPE_PROPERTY, auditableClient, null);
                Expression externaldeliverytypeExp = new AttributeExpression(typeAttibute, AttributeOperation.EQUALS,
                        "com.bosch.rtc.configuration.workitemtype.type.externaldelivery");
                //StartDate
                IQueryableAttribute startDateAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.CREATION_DATE_PROPERTY, auditableClient, null);
                Expression startDateExp = new AttributeExpression(startDateAttribute, AttributeOperation.AFTER,  startTime);
                //EndDate
                IQueryableAttribute endDateAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.CREATION_DATE_PROPERTY, auditableClient, null);
                Expression endDateExp = new AttributeExpression(endDateAttribute, AttributeOperation.BEFORE, endTime);
               
Term term = new Term(Term.Operator.AND);
 term.add(externaldeliverytypeExp);
 term.add(startDateExp);
 term.add(endDateExp);

But the above code  will list the work items which are created on 19th, 20th and 21st.  Why it results the work item created on 19th as well? Could anyone help me to find the right result.

Accepted answer


permanent link
David Honey (1.8k17) | answered Aug 26 '21, 8:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I don't know that API. However, I notice you haven't specified a time zone in either startDate or endDate. Hence those Date values are like to represent the time zone where that code is running. If it's running on a client, that will be your local time zone. Whereas the query itself will run on the server in its time zone. Perhaps that's the issue.

Prabhashree Poojary selected this answer as the correct answer

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.