Share via


MessageFormat.Format Method

Definition

Overloads

Format(String, Object[])

Formats an array of objects and appends the <code>MessageFormat</code>'s pattern, with format elements replaced by the formatted objects, to the provided <code>StringBuffer</code>.

Format(Object, StringBuffer, FieldPosition)

Formats an array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

Format(Object[], StringBuffer, FieldPosition)

Formats an array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

Format(String, Object[])

Formats an array of objects and appends the <code>MessageFormat</code>'s pattern, with format elements replaced by the formatted objects, to the provided <code>StringBuffer</code>.

[Android.Runtime.Register("format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", "")]
public static string? Format (string? pattern, params Java.Lang.Object[]? arguments);
[<Android.Runtime.Register("format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", "")>]
static member Format : string * Java.Lang.Object[] -> string

Parameters

pattern
String
arguments
Object[]

an array of objects to be formatted and substituted.

Returns

Attributes

Remarks

Java documentation for java.text.MessageFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(Object, StringBuffer, FieldPosition)

Formats an array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

[Android.Runtime.Register("format", "(Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "")]
public override sealed Java.Lang.StringBuffer? Format (Java.Lang.Object? arguments, Java.Lang.StringBuffer? result, Java.Text.FieldPosition? pos);
[<Android.Runtime.Register("format", "(Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "")>]
override this.Format : Java.Lang.Object * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

arguments
Object

an array of objects to be formatted and substituted.

result
StringBuffer

where text is appended.

pos
FieldPosition

keeps track on the position of the first replaced argument in the output string.

Returns

Attributes

Exceptions

if object is not an array of Object.

Remarks

Formats an array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer. This is equivalent to <blockquote> {@link #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) format}((Object[]) arguments, result, pos)</blockquote>

Java documentation for java.text.MessageFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(Object[], StringBuffer, FieldPosition)

Formats an array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

[Android.Runtime.Register("format", "([Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "")]
public Java.Lang.StringBuffer? Format (Java.Lang.Object[]? arguments, Java.Lang.StringBuffer? result, Java.Text.FieldPosition? pos);
[<Android.Runtime.Register("format", "([Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "")>]
override this.Format : Java.Lang.Object[] * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

arguments
Object[]

an array of objects to be formatted and substituted.

result
StringBuffer

where text is appended.

pos
FieldPosition

keeps track on the position of the first replaced argument in the output string.

Returns

the string buffer passed in as result, with formatted text appended

Attributes

Remarks

Formats an array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

The text substituted for the individual format elements is derived from the current subformat of the format element and the arguments element at the format element's argument index as indicated by the first matching line of the following table. An argument is unavailable if arguments is null or has fewer than argumentIndex+1 elements.

<table class="plain"> <caption style="display:none">Examples of subformat,argument,and formatted text</caption> <thead> <tr> <th scope="col">Subformat <th scope="col">Argument <th scope="col">Formatted Text </thead> <tbody> <tr> <th scope="row" style="text-weight-normal" rowspan=2>any<th scope="row" style="text-weight-normal">unavailable<td>"{" + argumentIndex + "}"<tr> <th scope="row" style="text-weight-normal">null<td>"null"<tr> <th scope="row" style="text-weight-normal">instanceof ChoiceFormat<th scope="row" style="text-weight-normal">any<td>subformat.format(argument).indexOf('{') &gt;= 0 ?<br> (new MessageFormat(subformat.format(argument), getLocale())).format(argument) : subformat.format(argument)<tr> <th scope="row" style="text-weight-normal">!= null<th scope="row" style="text-weight-normal">any<td>subformat.format(argument)<tr> <th scope="row" style="text-weight-normal" rowspan=4>null<th scope="row" style="text-weight-normal">instanceof Number<td>NumberFormat.getInstance(getLocale()).format(argument)<tr> <th scope="row" style="text-weight-normal">instanceof Date<td>DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale()).format(argument)<tr> <th scope="row" style="text-weight-normal">instanceof String<td>argument<tr> <th scope="row" style="text-weight-normal">any<td>argument.toString()</tbody> </table>

If pos is non-null, and refers to Field.ARGUMENT, the location of the first formatted string will be returned.

Java documentation for java.text.MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to