0
如何在ftl文件中打印當前月份?如何在FTL代碼中顯示當前月份?
如何在ftl文件中打印當前月份?如何在FTL代碼中顯示當前月份?
我真的不知道(也不能直接找到)FTL是什麼,所以請不要殺我,如果這不是你想要的。
但是:要獲得當月就可以使用的GregorianCalendar:
GregorianCalendar gc = new GregorianCalendar();
int month = gc.get(GregorianCalendar.MONTH);
假設你有一個配置已經和你正在做這樣的事情來處理它:
Template template = config.getTemplate("template.ftl");
Map<String,Object> model = new HashMap<String,Object>();
model.put("currentDate", new Date());
StringWriter writer = new StringWriter();
template.process(model, writer);
你可以通過做這樣的事情在template.ftl中引用你的日期:
Today's date is ${currentDate?string("MMMM")}!
T他MMMM
部分可以是任何字符串使用SimpleDateFormat語法
什麼是您嘗試使用FTLs(Hibernate逆向工程等)的應用程序?你試過什麼了?在這種情況下,多一點信息可能會有很大幫助。 – aperkins 2010-05-11 17:48:03