| 6 | import com.sen.api.utils.StringUtil; |
| 7 | |
| 8 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected