Last Updated: Jun 17, 2024
documentation for the dotCMS Content Management System

Tool for working with Number in Velocity templates. It is useful for accessing and formatting arbitrary Number objects. Also the tool can be used to retrieve NumberFormat instances or make conversions to and from various number types.

The following example shows how the NumberTool is mapped in the toolbox-xml file:



  $myNumber                            -> 13.55
  $number.format('currency',$myNumber) -> $13.55
  $number.format('integer',$myNumber)  -> 13

This tool is entirely threadsafe, and has no instance members. It may be used in any scope (request, session, or application). As such, the methods are highly interconnected, and overriding key methods provides an easy way to create subclasses that use a non-default format or locale.

On this page


We Dig Feedback

Selected excerpt: