public class MessageFormatter
extends java.lang.Object
format(String, Object) and
format(String, Object, Object) for more details.| Constructor and Description |
|---|
MessageFormatter() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
format(java.lang.String messagePattern,
java.lang.Object argument)
Performs single argument substitution for the 'messagePattern' passed as
parameter.
|
static java.lang.String |
format(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
/**
Performs a two argument substitution for the 'messagePattern' passed as
parameter.
|
public static java.lang.String format(java.lang.String messagePattern,
java.lang.Object argument)
For example, MessageFormatter.format("Hi {}.", "there"); will
return the string "Hi there.".
The {} pair is called the formatting element. It serves to designate the location where the argument needs to be inserted within the pattern.
messagePattern - The message pattern which will be parsed and formattedargument - The argument to be inserted instead of the formatting elementpublic static java.lang.String format(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
For example, MessageFormatter.format("Hi {}. My name is {}.",
"there", "David"); will return the string "Hi there. My name is David.".
The '{}' pair is called a formatting element. It serves to designate the location where the arguments need to be inserted within the message pattern.
messagePattern - The message pattern which will be parsed and formattedarg1 - The first argument to replace the first formatting elementarg2 - The second argument to replace the second formatting elementCopyright © 2006-2021 OPS4J - Open Participation Software for Java. All Rights Reserved.