MCPcopy Create free account
hub / github.com/ChenSen5/api_autotest / DateFunction

Class DateFunction

src/main/java/com/sen/api/functions/DateFunction.java:8–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import com.sen.api.utils.StringUtil;
7
8public class DateFunction implements Function{
9
10 @Override
11 public String execute(String[] args) {
12 if (args.length == 0 ||StringUtil.isEmpty(args[0])) {
13 return String.format("%s", new Date().getTime());
14 } else {
15 return getCurrentDate("yyyy-MM-dd");
16 }
17 }
18
19 private String getCurrentDate(String pattern) {
20 SimpleDateFormat format = new SimpleDateFormat(pattern);
21 String str = format.format(new Date());
22 return str;
23 }
24
25 @Override
26 public String getReferenceKey() {
27 // TODO Auto-generated method stub
28 return "date";
29 }
30
31}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected