public interface Format
${user.birthday,dateFormat='yyyy-MM-dd'}
${user.birthday,dateFormat}
1. dateFormat为格式化函数,通过groupTemplate的registerFormat函数注册,
2. 等号后面的字符串是需要格式化的样式,如果没有,可以不写
3. 格式化函数应该支持pattern为null的情况
public Object format(Object data, String pattern) {
if (data instanceof Date) {
SimpleDateFormat sdf = (pattern == null) ? new SimpleDateFormat() : new SimpleDateFormat(pattern);
return sdf.format(data);
}
throw new RuntimeException("Arg Error:Type should be Date");
}
Copyright © 2022. All rights reserved.