Object: dw.util.StringUtils

The Template Processor pre-imports dw.util.StringUtils, so the StringUtils class can be used within a template by its simple name.

Methods Description
static formatDate(date : Date) : String Formats a date with the default date format of the current site.
static formatInteger(number : Number) : String Returns a formatted integer number using the default integer format of the current site. The method can also be called to format a floating point as an integer.
static formatNumber(number : Number) : String Returns a formatted number using the default number format of the current site.
static garble(str : String, replaceChar : String, suffixLength : Number) : String Return a string in which a specified number of characters in the suffix isn't changed, and the rest of the characters are replaced with the specified character.
static pad(str : String, width : Number) : String Provides cell padding functionality to the template.
static stringToHtml(str : String) : String Converts a given string to an HTML-safe string. This method substitutes characters that conflict with HTML syntax (<,>,&,") and characters that are beyond the ASCII chart (Unicode 160-255) to HTML4.0 named character entities.
static stringToWml(str : String) : String Converts a given string to a WML-safe string. This method substitutes characters that conflict with WML syntax (<,>,&,&apos;,"$) to WML named entities.
static stringToXml(str : String) : String Converts a given string to an XML-safe string. This method substitutes characters that conflict with HTML syntax (<,>,&,") and characters that are beyond the ASCII chart (Unicode 160-255) to HTML4.0 named character entities.
static trim(str : String) : String Returns the string with leading and trailing white space removed.
static truncate(str : String, maxLength : Number, mode : String, suffix : String) : String Truncates the string to the specified length using specified truncate mode. Optionally, appends the suffix to a truncated string.

Example:

<isprint value="${StringUtils.pad("abc", 5)}"/>
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. By continuing to use this site you are giving us your consent to do this.