|
Hello,
I have a small EmailerService and I'm using *.gtpl files for processing the information. Now I have the case that I need to print out a date, to be more precisely a nice date. The use of ${dateCreated} is not what I want because I get the full date string, as expected. I need a way to print out a nice, formatted date within the template. What is the best way to get a nice date here? Is there a way of using <g:formatDate...> in the template somehow? Is there any other fancy trick to do so? What would you recommend? Thanks in advance... AGU |
|
Hey,
I don't know, whether it's possible to use the tags in a template. However, you could add a new Method to Date via the EMC which uses DateFormatter to return a formatted String: Date.metaClass.format { pattern -> .... } ${dateCreated.format('dd.mm.yyyy')} Cheers Christian
|
|
Ok, sounds good. But where do I put this? In the Domain class, Controller, Service?
Greets AGU
|
|
The Date.metaClass....-Part has to be put into the boostrap.groovy-init-Closure, I believe...
Cheers
|
| Powered by Nabble | Edit this page |
