mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for: ALF-11174: Advanced Search by Created Date doesn't work correctly
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31782 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,6 +21,7 @@ package org.alfresco.web.bean.search;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -371,15 +372,47 @@ public class AdvancedSearchDialog extends BaseDialogBean
|
||||
if (properties.isCreatedDateChecked())
|
||||
{
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat();
|
||||
String strCreatedDate = df.format(properties.getCreatedDateFrom());
|
||||
String strCreatedDateTo = df.format(properties.getCreatedDateTo());
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(properties.getCreatedDateFrom());
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
|
||||
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
|
||||
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
|
||||
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
|
||||
String strCreatedDate = df.format(cal.getTime());
|
||||
|
||||
cal.setTime(properties.getCreatedDateTo());
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
|
||||
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
|
||||
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
|
||||
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
cal.add(Calendar.MILLISECOND, -1);
|
||||
String strCreatedDateTo = df.format(cal.getTime());
|
||||
|
||||
search.addRangeQuery(ContentModel.PROP_CREATED, strCreatedDate, strCreatedDateTo, true);
|
||||
}
|
||||
if (properties.isModifiedDateChecked())
|
||||
{
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat();
|
||||
String strModifiedDate = df.format(properties.getModifiedDateFrom());
|
||||
String strModifiedDateTo = df.format(properties.getModifiedDateTo());
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(properties.getModifiedDateFrom());
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
|
||||
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
|
||||
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
|
||||
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
|
||||
String strModifiedDate = df.format(cal.getTime());
|
||||
|
||||
cal.setTime(properties.getModifiedDateTo());
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
|
||||
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
|
||||
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
|
||||
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
cal.add(Calendar.MILLISECOND, -1);
|
||||
String strModifiedDateTo = df.format(cal.getTime());
|
||||
|
||||
search.addRangeQuery(ContentModel.PROP_MODIFIED, strModifiedDate, strModifiedDateTo, true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user