throw new TemplateModelException(
"?" + biName + "(...) expects exactly 1 argument, but had "
+ args.size() + ".");
}
TemplateModel tzArgTM = (TemplateModel) args.get(0);
TimeZone tzArg;
Object adaptedObj;
if (tzArgTM instanceof AdapterTemplateModel
&& (adaptedObj =
((AdapterTemplateModel) tzArgTM)
.getAdaptedObject(TimeZone.class))
instanceof TimeZone) {
tzArg = (TimeZone) adaptedObj;
} else if (tzArgTM instanceof TemplateScalarModel) {
String tzName = ((TemplateScalarModel) tzArgTM).getAsString();
try {
tzArg = DateUtil.getTimeZone(tzName);
} catch (UnrecognizedTimeZoneException e) {
throw new TemplateModelException(
"The time zone string specified for ?" + biName +
"(...) is not recognized as a valid time zone name: " +
StringUtil.jQuote(tzName));
}
} else {
throw new TemplateModelException(
"The argument to ?" + biName +
"(...) must be a String or a " +
"java.util.TimeZone but it was a " +
(tzArgTM != null ? tzArgTM.getClass().getName() : "null") +
".");
}
return new SimpleScalar(DateUtil.dateToISO8601String(
date,