Luixv
Luixv

Reputation: 8710

Groovy date formatting problem

I am developing a groovy application and I am having problems when showing a Date field.

If I use the following notation:

<g:formatDate format="dd.MM.yyyy" date="${fieldValue(bean: incidentTicketSLAInstance, field: "erstellungsDatum")}"/>                     

I am getting the actual date instead of what is saved at the DB.

When I use this notation it works properly.

<g:formatDate format="dd.MM.yyyy" date="${incidentTicketSLAInstance?.erstellungsDatum}" />

am I doing something wrong here? Are not both notations equivalent? (BTW, the instance DO exists and erstellungsDatum is NOT null)

Thanks in advance,

Luis

Upvotes: 1

Views: 942

Answers (1)

tim_yates
tim_yates

Reputation: 171054

the fieldValue call will return a String, not a Date object, which the makes formatDate not work correctly

You have to use the second notation (as you spotted)

Upvotes: 1

Related Questions