### Question:
DateUtil { public static String expandDateMacro(String path) { StringBuffer sb = new StringBuffer(); Matcher matcher = DATE_MACRO_PATTERN.matcher(path); while (matcher.find()) { DateTimeFormatter formatter = null; boolean hourly = false; String match; if (matcher.group(4) != null) { formatter = DateTimeFormat.forPattern(matcher.group(4).substring(2)); } if (matcher.group(3) != null) { match = "{{now" + matcher.group(2) + Strings.nullToEmpty(matcher.group(5)) + "}}"; hourly = true; formatter = (formatter != null) ? formatter : ymdhFormatter; } else { match = "{{now" + matcher.group(1) + Strings.nullToEmpty(matcher.group(5)) + "}}"; formatter = (formatter != null) ? formatter : ymdFormatter; } matcher.appendReplacement(sb, com.addthis.hydra.data.util.DateUtil.getDateTime(formatter, match, hourly).toString(formatter)); } matcher.appendTail(sb); return sb.toString(); }  static DateTime getDateTime(String format, String date); static DateTime getDateTime(DateTimeFormatter formatter, String date); static DateTime getDateTime(DateTimeFormatter formatter, String date, boolean hourly); static String format(String format, long time); static String format(DateTimeFormatter formatter, long time); static DateTimeFormatter getFormatter(String format); static Iterator<DateTime> getDayIterator(final DateTime start, final DateTime end); static Iterator<DateTime> getHourIterator(final DateTime start, final DateTime end); static String expandDateMacro(String path); static final String NOW_PREFIX; static final String NOW_POSTFIX; static final String OFF; static final String NOW; }### Answer:
@Test public void expandDateMacro() { String expanded = DateUtil.expandDateMacro("{{now}}/{{now-1}},{{now}},123442/{{now, {{now}}"); String now = DateUtil.getDateTime(DateUtil.ymdFormatter, "{{now}}").toString(DateUtil.ymdFormatter); String nowMinus1 = DateUtil.getDateTime(DateUtil.ymdFormatter, "{{now-1}}").toString(DateUtil.ymdFormatter); assertEquals(String.format("%s/%s,%s,123442/{{now, %s",now,nowMinus1,now,now), expanded); }