Reputation: 152226
Is it possible to print current date in specified format (Y-m-d H:i:s
) in ftl (FreeMarker) ?
I want to avoid passing date from controller to view.
Upvotes: 3
Views: 5515
Reputation: 26860
Tying up to the above answer: Once you place date object into your model you do this:
date?string("yy-MM-dd HH:mm:ss")
Upvotes: 2
Reputation: 11435
Freemarker is a templating library, there isn't a today variable, you should consider passing a new Date()
Java Object to the template, and format it. Consider to create a wrapper class for this, to generate the new Date() exactly at the time it is called.
Upvotes: 2