I want to query RTC with modified date. My query is to check modified date is same as given date and time but the response that I am getting is based on given date and it is ignoring time.
Response:
Queried Date: 08/07/2015 15:44:09
Id: 2583 Modified date :2015-08-07 14:43:19.157
Id: 2582 Modified date :2015-08-07 14:43:19.419
Ideally, both the records should not be received in response as it is before given time.
Below is my code:
IQueryableAttributeFactory factory = QueryableAttributes.getFactory( IWorkItem.ITEM_TYPE );
IQueryableAttribute recAttr1 = factory.findAttribute(projectArea, IItem.MODIFIED_PROPERTY, auditableClient, null );
IQueryableAttribute recAttr2 = factory.findAttribute(projectArea, IWorkItem.TYPE_PROPERTY, auditableClient, null );
Date date = new Date();
date.setDate(date.getDate()-6);
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String reportDate = df.format(date);
System.out.println("Date: "+reportDate);
Timestamp timeStamp = new Timestamp(date.getTime());
AttributeExpression recExpr1 = new AttributeExpression(recAttr1, AttributeOperation.EQUALS, timeStamp );
Term term= new Term(Operator.AND);
term.add(recExpr1);
IQueryClient queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);
IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(projectArea, (Expression)term, IWorkItem.FULL_PROFILE);
System.out.println("This is total number: "+result.getResultSize(monitor).getTotal()+"\n");
while(result.hasNext(null)){
IResolvedResult<IWorkItem> resolvedWorkItem = result.next(null);
IWorkItem workItem = resolvedWorkItem.getItem();
Date date1 = resolvedWorkItem.getItem().modified();
System.out.println("Id: "+workItem.getId());
System.out.println("Modified date :"+date1.toString()+"\n");
}
Can I get result not only based on date but also on time?
I strongly feel that the back-end logic of RTC is completely ignoring time and querying database only based on date.