Constructs messages from a pattern and parameters. A message format takes a list of arguments, formats
them, and inserts them into the pattern at specific places.
Replacement tokens are delimited with curly braces. Tokens begin with an integer, which determines the format
parameter that is inserted in place of the token. The following tokens are supported where
n is the
zero-based parameter index:
-
{n} — Replaced with the nth parameter. The formatting of the nth parameter,
param,
depends on its data type:
-
null — "null"
-
string — param
-
number — {n,number}
-
Object — param.toString()
-
Date — {n,datetime,short}
- Not provided — "{n}"
-
{n,date} — Formats the nth parameter as a date with the default format length (medium).
-
{n,date,[short|medium|long|full|format]} — Formats the nth parameter as a date according to the
specified format length or an arbitrary date format.
-
{n,time} — Formats the nth parameter as a time with the default format length (medium).
-
{n,time,[short|medium|long|full|format]} — Formats the nth parameter as a time according to the
specified format length or an arbitrary date format.
-
{n,datetime} — Formats the nth parameter as a date/time with the default format length (medium).
-
{n,datetime,[short|medium|long|full|format]} — Formats the nth parameter as a date/time according to the
specified format length or an arbitrary date format.
-
{n,number} — Formats the nth parameter as a number with the default number format.
-
{n,number,[integer|percent|currency|format]} — Formats the nth parameter as a number according
to the specified number format type or an arbitrary number format.
The formatting of date, time, datetime, and number tokens depends on the locale of the message format. The formats
used to format such tokens inherit their locale from the message format. If no locale is passed to the message
format constructor, the default system locale is used.
Within a format, single quotes (') delimit quoted sequences that are not parsed for tokens. Therefore, in order
to insert a curly bracket in a message format, it should be surrounded by single quotes:
new MessageFormat("A curly bracket: '{'"). To insert a single quote character, use two single
quotes in succession:
new MessageFormat("A single quote: ''").
The instance initializer.
Parameters:
strFormat – the format pattern.
objLocale – the locale of the format. The locale affects how numbers and dates are
formatted. If this parameter is omitted, the system locale is used.
Throws:
Formats a collection of objects according to this message format.
Parameters:
args – the argument objects. Replacement tokens of the pattern of this format
will be replaced by these arguments.
Returns:
the string resulting from the pattern and arguments.
Returns the locale of this message format.
Returns:
Sets the locale of this message format.
Parameters:
Copyright © 2001-2011, TIBCO Software Inc.