grails - How to override Joda-Time GSP tag output -
I am using the add-on plug-in for Grails, and so far it is helping a lot . A massive improvement over the Java date / caller method. Anyway, I am rendering period data using GSP tags:
& lt; joda: formatPeriod value = "$ {shift .totalTime}" field = "hours, minutes" /> As HTML tag, provides 11 hours and 32 minutes . It's great, but I would override the text and change it to 11hrs at 32min. . Is anyone experiencing this? I have not got any examples as I have goggles intergues. I feel that this will help many others.
BTW: I am truly grateful for the creators of the add-on time. This is one of the most useful libraries / plugins I've found.
If you are not concerned about localized text and only hours and minutes, then a simple solution To formatting, you must write your small tag. Something like this:
DF format period = {eterts -> FDF Period Format = New Period FormTime (). Appendhores (). Andandsfix ("etars.") Append Asperator (""). Appendments (). AndandsFix ("min."). Toformer () Out & lt; & Lt; PeriodFormatter.print (attrs.value)} Here is the sample output from the Groove Shell:
groovy: 000> Period = New period () Together (11) .withMinutes (32) === & gt; PT11H32M Groovy: 000 & gt; formatter = PeriodFormat.wordBased () === & gt; org.joda.time.format.PieriodFormatter@6d2deeeee groovy: 000 & gt; Formatter.print (period) === & gt; In the 11 hours and 32 minutes, the survivor: 000 & gt; Adendasfeetter (""). Appendments (). Andandsfix ("min."). Toformer () === & gt; org.joda.time.format.PeriodFormatter@56048075 groovy: 000> PeriodFormatter.print (period) === & gt; 11hrs 32min
Comments
Post a Comment