Source:
<code>public List<FeedbackSessionAttributes> getAllOpenFeedbackSessions(Instant rangeStart, Instant rangeEnd) { List<FeedbackSessionAttributes> list = new LinkedList<>(); Calendar startCal = Calendar.getInstance(); startCal.setTime(TimeHelper.convertInstantToDate(rangeStart)); Calendar endCal = Calendar.getInstance(); <START> endCal.setTime(TimeHelper.convertInstantToDate(rangeEnd)); <END> Date curStart = TimeHelper.convertToUserTimeZone(startCal, -25).getTime(); Date curEnd = TimeHelper.convertToUserTimeZone(endCal, 25).getTime(); List<FeedbackSession> endEntities = load() .filter("endTime >", curStart) .filter("endTime <=", curEnd) .list(); List<FeedbackSession> startEntities = load() .filter("startTime >=", curStart) .filter("startTime <", curEnd) .list(); List<FeedbackSession> endTimeEntities = new ArrayList<>(endEntities); List<FeedbackSession> startTimeEntities = new ArrayList<>(startEntities); endTimeEntities.removeAll(startTimeEntities); startTimeEntities.removeAll(endTimeEntities); endTimeEntities.addAll(startTimeEntities); for (FeedbackSession feedbackSession : endTimeEntities) { FeedbackSessionAttributes fs = makeAttributes(feedbackSession); Instant fsStart = fs.getStartTime(); Instant fsEnd = fs.getEndTime(); boolean isStartTimeWithinRange = (fsStart.isAfter(rangeStart) || fsStart.equals(rangeStart)) && fsStart.isBefore(rangeEnd); boolean isEndTimeWithinRange = fsEnd.isAfter(rangeStart) && (fsEnd.isBefore(rangeEnd) || fsEnd.equals(rangeEnd)); if (isStartTimeWithinRange || isEndTimeWithinRange) { list.add(fs); } } return list; }</code><technical_language>refactor line 46 47 deprecated convertToUserTimeZone? I Calendar type here. do in Instant 1 final step convert Instant Date passing a library method needs a Date, (Objectify's filter in this case). Objectify finally support Instant, delete conversion</technical_language>

Target:
public List<FeedbackSessionAttributes> getAllOpenFeedbackSessions(Instant rangeStart, Instant rangeEnd) { List<FeedbackSessionAttributes> list = new LinkedList<>(); Instant start = rangeStart.minus(Duration.ofHours(25)); Instant end = rangeEnd.plus(Duration.ofHours(25)); List<FeedbackSession> endEntities = load() .filter("endTime >", TimeHelper.convertInstantToDate(start)) .filter("endTime <=", TimeHelper.convertInstantToDate(end)) .list(); List<FeedbackSession> startEntities = load() .filter("startTime >=", TimeHelper.convertInstantToDate(start)) .filter("startTime <", TimeHelper.convertInstantToDate(end)) .list(); List<FeedbackSession> endTimeEntities = new ArrayList<>(endEntities); List<FeedbackSession> startTimeEntities = new ArrayList<>(startEntities); endTimeEntities.removeAll(startTimeEntities); startTimeEntities.removeAll(endTimeEntities); endTimeEntities.addAll(startTimeEntities); for (FeedbackSession feedbackSession : endTimeEntities) { FeedbackSessionAttributes fs = makeAttributes(feedbackSession); Instant fsStart = fs.getStartTime(); Instant fsEnd = fs.getEndTime(); boolean isStartTimeWithinRange = (fsStart.isAfter(rangeStart) || fsStart.equals(rangeStart)) && fsStart.isBefore(rangeEnd); boolean isEndTimeWithinRange = fsEnd.isAfter(rangeStart) && (fsEnd.isBefore(rangeEnd) || fsEnd.equals(rangeEnd)); if (isStartTimeWithinRange || isEndTimeWithinRange) { list.add(fs); } } return list; }