enjoy 3.3 release ^_^

This commit is contained in:
James
2017-11-21 22:43:34 +08:00
parent 28eb105ffa
commit 61aa1d2082
70 changed files with 3378 additions and 299 deletions

View File

@@ -16,12 +16,13 @@
package com.jfinal.template.ext.directive;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.io.IOException;
import java.util.Date;
import com.jfinal.template.Directive;
import com.jfinal.template.Env;
import com.jfinal.template.TemplateException;
import com.jfinal.template.expr.ast.ExprList;
import com.jfinal.template.io.Writer;
import com.jfinal.template.stat.ParseException;
import com.jfinal.template.stat.Scope;
@@ -39,22 +40,21 @@ public class NowDirective extends Directive {
}
public void exec(Env env, Scope scope, Writer writer) {
String dataPattern;
String datePattern;
if (exprList.length() == 0) {
dataPattern = env.getEngineConfig().getDatePattern();
datePattern = env.getEngineConfig().getDatePattern();
} else {
Object dp = exprList.eval(scope);
if (dp instanceof String) {
dataPattern = (String)dp;
datePattern = (String)dp;
} else {
throw new TemplateException("The parameter of #new directive must be String", location);
throw new TemplateException("The parameter of #now directive must be String", location);
}
}
try {
String value = new SimpleDateFormat(dataPattern).format(new java.util.Date());
write(writer, value);
} catch (Exception e) {
writer.write(new Date(), datePattern);
} catch (IOException e) {
throw new TemplateException(e.getMessage(), location, e);
}
}