From 9c99b109772e176e1f65175fe4234320701a6ac6 Mon Sep 17 00:00:00 2001 From: Andrea Gazzarini Date: Wed, 19 Aug 2020 12:47:44 +0200 Subject: [PATCH] [ 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 --- .../alfresco/solr/query/Solr4QueryParser.java | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/query/Solr4QueryParser.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/query/Solr4QueryParser.java index e7dd53349..d8fe79b41 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/query/Solr4QueryParser.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/query/Solr4QueryParser.java @@ -4483,8 +4483,7 @@ private String getDateEnd(Pair dateAndResolution) } /** - * @param dateAndResolution - * @return + * Returns the formatted start (i.e. lower bound) of a range query. */ private String getDateStart(Pair dateAndResolution) { @@ -4492,39 +4491,37 @@ private String getDateStart(Pair dateAndResolution) cal.setTime(dateAndResolution.getFirst()); switch (dateAndResolution.getSecond()) { - case Calendar.YEAR: - cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH)); - case Calendar.MONTH: - cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); - case Calendar.DAY_OF_MONTH: - cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY)); - case Calendar.HOUR_OF_DAY: - cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE)); - case Calendar.MINUTE: - cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); - case Calendar.SECOND: - cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND)); - case Calendar.MILLISECOND: - default: + case Calendar.YEAR: + cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH)); + case Calendar.MONTH: + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); + case Calendar.DAY_OF_MONTH: + cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY)); + case Calendar.HOUR_OF_DAY: + cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE)); + case Calendar.MINUTE: + cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); + case Calendar.SECOND: + cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND)); + case Calendar.MILLISECOND: + default: } - SimpleDateFormat formatter = CachingDateFormat.getSolrDatetimeFormat(); - formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - return formatter.format(cal.getTime()); + return CachingDateFormat.getSolrDatetimeFormat().format(cal.getTime()); } private Pair parseDateString(String dateString) { try { - Pair result = CachingDateFormat.lenientParse(dateString, Calendar.YEAR); - return result; + return CachingDateFormat.lenientParse(dateString, Calendar.YEAR); } catch (java.text.ParseException e) { SimpleDateFormat oldDf = CachingDateFormat.getDateFormat(); + oldDf.setTimeZone(TimeZone.getTimeZone("UTC")); try { Date date = oldDf.parse(dateString); - return new Pair(date, Calendar.SECOND); + return new Pair<>(date, Calendar.SECOND); } catch (java.text.ParseException ee) { if (dateString.equalsIgnoreCase("min"))