# <netui:formatString> Tag

A formatter used to format strings.

## Syntax

<netui:formatString
[country="string_country"]
[language="string_language"]
pattern="string_simpleDataFormat"
[truncate="boolean_truncate"] />

## Description

A formatter used to format strings.

The <netui:formatString> tag formats the output of its parent tag. For example:

         <netui:label value="{pageFlow.phone}">
             <netui:formatString pattern="phone number: (###) ###-####"/>
         </netui:label>

<netui:formatString> uses the following pattern syntax:

The # character is a placeholder for individual characters in the String to be formatted, while other characters are treated as literals. For example:

String "5555555555" with pattern "(###)###-####" would result in: (555)555-5555.

The * character displays all remaining characters in the String. For example:

String "123456" with pattern "#-*!" would result in: 1-23456!

If a result with a '#' or '*' character showing is desired, the '#' or '*' needs to be escaped with the '$' character. For example:

String "ABCD" with pattern "$#-####" would result in: #-ABCD.

To show a '$' in the result, the '$' character needs to be escaped. For example:

String "1234" with pattern "$$#,###" would result in: $1,234

If the `truncate` attribute is set to "true", characters in the String that exceed the pattern will be dropped. Otherwise, they will be appended to the end of the formatted String.

## Attributes

country | Determines a formatting style for the specified country. The `country` attribute takes an uppercase, two letter code as defined by ISO-3166. For a list of country codes see ISO-3166 Country Codes
Required | Supports runtime expression evaluation | Data bindable
No | No | No
language | Determines a formatting style for the specified language. The `language` attribute is optional, but it must be set when the `country` attribute is set. The `language` attribute takes a lowercase, two letter code as defined by ISO-639. For a list of language codes see ISO-639 Language Codes
Required | Supports runtime expression evaluation | Data bindable
No | No | No
pattern | The pattern used to format the input. For detailed information on pattern syntax see java.text.DecimalFormat .
Required | Supports runtime expression evaluation | Data bindable
Yes | No | Read Only
truncate | A boolean specifying whether characters that exceed the pattern's length should be dropped.
Required | Supports runtime expression evaluation | Data bindable
No | No | No

## Sample

In this sample, the String "2125555555" will be formatted to this form: (212)555-5555.

        <netui:label value="2125555555">
            <netui:formatString pattern="phone (###) ###-####"/>
        </netui:label>

## Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/formatTags/index.jsp

## Related Topics

<netui:format...> Tag Samples

<netui:formatDate> Tag

<netui:formatNumber> Tag