I am trying to print the current date when the template is activated. I have read that I have to pass a new Date() Java object to the template, but I don\'t know how to do that
Actually you don't have to pass a new Date()
to your template, because placing a timestamp into a template's output is quite common and therefore FreeMarker provides a special variable called .now
which returns the current date and time. You can use it in your template like this:
Page generated: ${.now}
(FreeMarker also contains different built-ins for formatting dates: http://freemarker.org/docs/ref_builtins_date.html)
Update: Works only with the latest version of FreeMarker, 2.3.17.