mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +00:00
[ SEARCH-2376 ] Fix timezone mgmt on IE (#904)
* [ SEARCH-2376 ] Fix timezone mgmt on IE * [ SEARCH-2376 ] Restrict the test timezones by unique offset + Junit repeater (cherry picked from commit bb88db5864b4c1713d2681268e29a0c74f03e2ec)
This commit is contained in:
committed by
agazzarini
parent
2b683b055c
commit
29d1c7f438
@@ -4483,8 +4483,7 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dateAndResolution
|
* Returns the formatted start (i.e. lower bound) of a range query.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private String getDateStart(Pair<Date, Integer> dateAndResolution)
|
private String getDateStart(Pair<Date, Integer> dateAndResolution)
|
||||||
{
|
{
|
||||||
@@ -4492,39 +4491,37 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
|
|||||||
cal.setTime(dateAndResolution.getFirst());
|
cal.setTime(dateAndResolution.getFirst());
|
||||||
switch (dateAndResolution.getSecond())
|
switch (dateAndResolution.getSecond())
|
||||||
{
|
{
|
||||||
case Calendar.YEAR:
|
case Calendar.YEAR:
|
||||||
cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
|
cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
|
||||||
case Calendar.MONTH:
|
case Calendar.MONTH:
|
||||||
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
|
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||||
case Calendar.DAY_OF_MONTH:
|
case Calendar.DAY_OF_MONTH:
|
||||||
cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));
|
cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));
|
||||||
case Calendar.HOUR_OF_DAY:
|
case Calendar.HOUR_OF_DAY:
|
||||||
cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));
|
cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));
|
||||||
case Calendar.MINUTE:
|
case Calendar.MINUTE:
|
||||||
cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));
|
cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));
|
||||||
case Calendar.SECOND:
|
case Calendar.SECOND:
|
||||||
cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND));
|
cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND));
|
||||||
case Calendar.MILLISECOND:
|
case Calendar.MILLISECOND:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
SimpleDateFormat formatter = CachingDateFormat.getSolrDatetimeFormat();
|
return CachingDateFormat.getSolrDatetimeFormat().format(cal.getTime());
|
||||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
||||||
return formatter.format(cal.getTime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<Date, Integer> parseDateString(String dateString)
|
private Pair<Date, Integer> parseDateString(String dateString)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Pair<Date, Integer> result = CachingDateFormat.lenientParse(dateString, Calendar.YEAR);
|
return CachingDateFormat.lenientParse(dateString, Calendar.YEAR);
|
||||||
return result;
|
|
||||||
} catch (java.text.ParseException e)
|
} catch (java.text.ParseException e)
|
||||||
{
|
{
|
||||||
SimpleDateFormat oldDf = CachingDateFormat.getDateFormat();
|
SimpleDateFormat oldDf = CachingDateFormat.getDateFormat();
|
||||||
|
oldDf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Date date = oldDf.parse(dateString);
|
Date date = oldDf.parse(dateString);
|
||||||
return new Pair<Date, Integer>(date, Calendar.SECOND);
|
return new Pair<>(date, Calendar.SECOND);
|
||||||
} catch (java.text.ParseException ee)
|
} catch (java.text.ParseException ee)
|
||||||
{
|
{
|
||||||
if (dateString.equalsIgnoreCase("min"))
|
if (dateString.equalsIgnoreCase("min"))
|
||||||
|
Reference in New Issue
Block a user