common:formatter

This lets you format dates (including calendar-objects), numbers (Integers, Long, Double, Float) into different formats based on a pattern and locale.

Parameters

The result variable name.

Name Required Default Type Description
id false   String .
type false   Object/String If you set “fileSize” and supply a number a special formatting will kick in.
value true   Object/String The value to format.
pattern false Different Object/String The pattern to use when formatting.
For dates it’s SimpleDateFormat patterns you use and for Numbers you
use DecimalFormat-pattens.
locale false   Object/String The locale to use when formatting.
         

 

Examples

This example formats a news date to ISO-format.

<content:matchingContents id="articles"
contentTypeDefinitionNames="Article,News"
categoryCondition="Area=/Areas/Medicine"/>
<c:forEach var="article" items="${articles}" varStatus="count">
<content:contentAttribute id="Title" contentId="${article.contentId}"
attributeName="Title"/>
<c:out value="${Title}"/> - <common:formatter
value="${article.publishDateTime}" pattern="yyyy-MM-dd"><br/>
</c:forEach>


Look at patterns for dates here:
http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
Look at patterns for numbers here:
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html



comments powered by Disqus