### Question:
SqlReplacer { static String replaceDatePlaceholder(ZonedDateTime now, String sql) { Matcher m = RELATIVE_DATE_PATTERN.matcher(sql); StringBuffer sb = new StringBuffer(sql.length()); while (m.find()) { long daysToShift = Long.parseLong(m.group(1)); String daysAsStringDate = formatToSqlDate(now, daysToShift); m.appendReplacement(sb, daysAsStringDate); } m.appendTail(sb); return sb.toString(); } private  SqlReplacer();   }### Answer:
@Test void replaceRelativeTimeFunctionSameDate() { ZonedDateTime now = Instant.now().atZone(ZoneId.of("UTC")); String dateFormatted = now.format(DATE_TIME_FORMATTER); String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(0) ..."); assertThat(sqlStringReplaced).contains(dateFormatted); }
@Test void replaceRelativeTimeFunctionPosDate() { ZonedDateTime now = Instant.now().atZone(ZoneId.of("UTC")); String dateFormatted = now.plusDays(5).format(DATE_TIME_FORMATTER); String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(5) ..."); assertThat(sqlStringReplaced).contains(dateFormatted); }
@Test void replaceRelativeTimeFunctionNegDate() { ZonedDateTime now = Instant.now().atZone(ZoneId.of("UTC")); String dateFormatted = now.plusDays(-10).format(DATE_TIME_FORMATTER); String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(-10) ..."); assertThat(sqlStringReplaced).contains(dateFormatted); }