quaff
quaff

Reputation: 71

How to avoid null when formatting value

${date?string('yyyy-MM-dd')}

if date is null, freemarker will raise a exception

here is a solution

<#if date??>${date?string('yyyy-MM-dd')}</#if>

but this code is ugly,is there any shortcut like ${date!} ?

Upvotes: 3

Views: 2406

Answers (1)

vigor
vigor

Reputation: 261

You can write

${(p.bd?string("dd/MM/yyyy"))!}

Upvotes: 11

Related Questions