Date format in a FreeMarker Template

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 09:35 AM
Hi, folks!
I am trying to use the following code to format a date field to the Brazilian fomat ("DD/MM/YYYY"):
${news.PublishedDate.string("yyyy-MM-dd")}
But, when Alfresco render the web form content, I get this error:
Error generating rendition using radio_final.ftl: freemarker.template.TemplateException: Expected method. radionovo.DataPublicacao.string evaluated instead to freemarker.ext.dom.NodeListModel on line 71, column 19 in freemarker_template.
What could be wrong? Is there another way to do this formatting?
Tks!
I am trying to use the following code to format a date field to the Brazilian fomat ("DD/MM/YYYY"):
${news.PublishedDate.string("yyyy-MM-dd")}
But, when Alfresco render the web form content, I get this error:
Error generating rendition using radio_final.ftl: freemarker.template.TemplateException: Expected method. radionovo.DataPublicacao.string evaluated instead to freemarker.ext.dom.NodeListModel on line 71, column 19 in freemarker_template.
What could be wrong? Is there another way to do this formatting?
Tks!
Labels:
- Labels:
-
Archive
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 11:08 PM
Hi Try this,
"${news.PublishedDate?datetime?string("yyyy-MM-dd")}"
Thanks,
Patil
Cignex Technologies
Bangalore
"${news.PublishedDate?datetime?string("yyyy-MM-dd")}"
Thanks,
Patil
Cignex Technologies
Bangalore
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2011 04:39 PM
Hi
I tried the way you suggested for formatting my date, but I got the following exception
Here is my the line that throws that error.
Can you let me know what I am doing wrong here.
Thanks
I tried the way you suggested for formatting my date, but I got the following exception
Error generating rendition using news.ftl: freemarker.core.NonStringException: Error on line 236, column 104 in freemarker_template Expecting a string, date or number here, Expression press_release.launch_date is instead a freemarker.ext.dom.NodeListModel
Here is my the line that throws that error.
${press_release.launch_date?datetime?string("MMM dd, yyyy")}
Can you let me know what I am doing wrong here.
Thanks

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2011 11:14 AM
Hi
Expecting a string, date or number here, Expression press_release.launch_date
Looks like launch_date is not String or date. It is collection.
Thanks,
Patil
Cignex Technologies
Bangalore
Expecting a string, date or number here, Expression press_release.launch_date
Looks like launch_date is not String or date. It is collection.
Thanks,
Patil
Cignex Technologies
Bangalore
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2011 05:52 PM
I dont think it is a Collection, unless I am missing something. here is my xsd file for the web form.
Please let me know how to format the date value in "launch_date" which is in "MM/DD/YYYY" format to "MMM DD, YYYY".
Thanks
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:pr="http://www.alfresco.org/alfresco/pr" xmlns:alf="http://www.alfresco.org" targetNamespace="http://www.alfresco.org/alfresco/pr" elementFormDefault="qualified"> <!– defines the form for creating a press release –> <xs:element name="press_release"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:normalizedString"/> <xs:element name="body" type="xs:string" minOccurs="1" maxOccurs="unbounded"/> <xs:element name="launch_date" type="xs:date"/> <xs:element name="expiration_date" type="xs:date"/> </xs:sequence> </xs:complexType> </xs:element></xs:schema>
Please let me know how to format the date value in "launch_date" which is in "MM/DD/YYYY" format to "MMM DD, YYYY".
Thanks
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2011 04:31 PM
Ahh figured it out.
Ftl rendering engine was returning date as a string in "yyyy-mm-dd" format. I had to convert it to date value in the same format to render it "MMM dd, yyyy" format. For eg.
Hope this helps to someone else.
Cheers
Ftl rendering engine was returning date as a string in "yyyy-mm-dd" format. I had to convert it to date value in the same format to render it "MMM dd, yyyy" format. For eg.
${press_release.launch_date?date("yyyy-MM-dd")}
Hope this helps to someone else.
Cheers
