@Test public void getReportOutput_パターン2つ() { String input = "report_{yyyyMMdd}-{HHmm}.html"; String actual = AntParameterUtil.getReportOutput(input); String expected = "report_" + new SimpleDateFormat("yyyyMMdd-HHmm").format(new Date()) + ".html"; assertEquals(expected, actual); }
public static String getReportOutput(String s) throws IllegalArgumentException { Pattern formatPattern = Pattern.compile("(.+)\\{(.+)\\}(.+)"); String replaced = s; Matcher matcher; Date now = new Date(); while ((matcher = formatPattern.matcher(replaced)).matches()) { replaced = matcher.group(1) + new SimpleDateFormat(matcher.group(2)).format(now) + matcher.group(3); } return replaced; }
AntParameterUtil { public static String getReportOutput(String s) throws IllegalArgumentException { Pattern formatPattern = Pattern.compile("(.+)\\{(.+)\\}(.+)"); String replaced = s; Matcher matcher; Date now = new Date(); while ((matcher = formatPattern.matcher(replaced)).matches()) { replaced = matcher.group(1) + new SimpleDateFormat(matcher.group(2)).format(now) + matcher.group(3); } return replaced; } }
AntParameterUtil { public static String getReportOutput(String s) throws IllegalArgumentException { Pattern formatPattern = Pattern.compile("(.+)\\{(.+)\\}(.+)"); String replaced = s; Matcher matcher; Date now = new Date(); while ((matcher = formatPattern.matcher(replaced)).matches()) { replaced = matcher.group(1) + new SimpleDateFormat(matcher.group(2)).format(now) + matcher.group(3); } return replaced; } private  AntParameterUtil(); }
AntParameterUtil { public static String getReportOutput(String s) throws IllegalArgumentException { Pattern formatPattern = Pattern.compile("(.+)\\{(.+)\\}(.+)"); String replaced = s; Matcher matcher; Date now = new Date(); while ((matcher = formatPattern.matcher(replaced)).matches()) { replaced = matcher.group(1) + new SimpleDateFormat(matcher.group(2)).format(now) + matcher.group(3); } return replaced; } private  AntParameterUtil(); static String getReportOutput(String s); static String parseToday(String s); }
AntParameterUtil { public static String getReportOutput(String s) throws IllegalArgumentException { Pattern formatPattern = Pattern.compile("(.+)\\{(.+)\\}(.+)"); String replaced = s; Matcher matcher; Date now = new Date(); while ((matcher = formatPattern.matcher(replaced)).matches()) { replaced = matcher.group(1) + new SimpleDateFormat(matcher.group(2)).format(now) + matcher.group(3); } return replaced; } private  AntParameterUtil(); static String getReportOutput(String s); static String parseToday(String s);  }