Skip to content

Commit

Permalink
[ SEARCH-2376 ] Fix timezone mgmt on IE (#904)
Browse files Browse the repository at this point in the history
* [ SEARCH-2376 ] Fix timezone mgmt on IE

* [ SEARCH-2376 ] Restrict the test timezones by unique offset + Junit repeater
  • Loading branch information
agazzarini authored Aug 19, 2020
1 parent 37d5fb2 commit 9c99b10
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4483,48 +4483,45 @@ private String getDateEnd(Pair<Date, Integer> dateAndResolution)
}

/**
* @param dateAndResolution
* @return
* Returns the formatted start (i.e. lower bound) of a range query.
*/
private String getDateStart(Pair<Date, Integer> dateAndResolution)
{
Calendar cal = Calendar.getInstance(I18NUtil.getLocale());
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<Date, Integer> parseDateString(String dateString)
{
try
{
Pair<Date, Integer> 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, Integer>(date, Calendar.SECOND);
return new Pair<>(date, Calendar.SECOND);
} catch (java.text.ParseException ee)
{
if (dateString.equalsIgnoreCase("min"))
Expand Down

0 comments on commit 9c99b10

Please sign in to comment.