Share via


NumberFormat.Format Method

Definition

Overloads

Format(Double)

Specialization of format.

Format(Int64)

Specialization of format.

Format(Object, StringBuffer, FieldPosition)

Formats a number and appends the resulting text to the given string buffer.

Format(Double, StringBuffer, FieldPosition)

Specialization of format.

Format(Int64, StringBuffer, FieldPosition)

Specialization of format.

Format(Double)

Specialization of format.

[Android.Runtime.Register("format", "(D)Ljava/lang/String;", "")]
public string Format (double number);
[<Android.Runtime.Register("format", "(D)Ljava/lang/String;", "")>]
override this.Format : double -> string

Parameters

number
Double

the double number to format

Returns

the formatted String

Attributes

Remarks

Specialization of format.

Java documentation for java.text.NumberFormat.format(double).

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(Int64)

Specialization of format.

[Android.Runtime.Register("format", "(J)Ljava/lang/String;", "")]
public string Format (long number);
[<Android.Runtime.Register("format", "(J)Ljava/lang/String;", "")>]
override this.Format : int64 -> string

Parameters

number
Int64

the long number to format

Returns

the formatted String

Attributes

Remarks

Specialization of format.

Java documentation for java.text.NumberFormat.format(long).

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 a number and appends the resulting text to the given string buffer.

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

Parameters

number
Object

the number to format

toAppendTo
StringBuffer

the StringBuffer to which the formatted text is to be appended

pos
FieldPosition

keeps track on the position of the field within the returned string. For example, for formatting a number 1234567.89 in Locale.US locale, if the given fieldPosition is NumberFormat#INTEGER_FIELD, the begin index and end index of fieldPosition will be set to 0 and 9, respectively for the output string 1,234,567.89.

Returns

the value passed in as toAppendTo

Attributes

Exceptions

if object is not an instance of Number.

Remarks

Formats a number and appends the resulting text to the given string buffer. The number can be of any subclass of java.lang.Number.

This implementation extracts the number's value using java.lang.Number#longValue() for all integral type values that can be converted to long without loss of information, including BigInteger values with a java.math.BigInteger#bitLength() bit length of less than 64, and java.lang.Number#doubleValue() for all other types. It then calls #format(long,java.lang.StringBuffer,java.text.FieldPosition) or #format(double,java.lang.StringBuffer,java.text.FieldPosition). This may result in loss of magnitude information and precision for BigInteger and BigDecimal values.

Java documentation for java.text.NumberFormat.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(Double, StringBuffer, FieldPosition)

Specialization of format.

[Android.Runtime.Register("format", "(DLjava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_DLjava_lang_StringBuffer_Ljava_text_FieldPosition_Handler")]
public abstract Java.Lang.StringBuffer Format (double number, Java.Lang.StringBuffer toAppendTo, Java.Text.FieldPosition pos);
[<Android.Runtime.Register("format", "(DLjava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_DLjava_lang_StringBuffer_Ljava_text_FieldPosition_Handler")>]
override this.Format : double * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

number
Double

the double number to format

toAppendTo
StringBuffer

the StringBuffer to which the formatted text is to be appended

pos
FieldPosition

keeps track on the position of the field within the returned string. For example, for formatting a number 1234567.89 in Locale.US locale, if the given fieldPosition is NumberFormat#INTEGER_FIELD, the begin index and end index of fieldPosition will be set to 0 and 9, respectively for the output string 1,234,567.89.

Returns

the formatted StringBuffer

Attributes

Remarks

Specialization of format.

Java documentation for java.text.NumberFormat.format(double, 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(Int64, StringBuffer, FieldPosition)

Specialization of format.

[Android.Runtime.Register("format", "(JLjava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_JLjava_lang_StringBuffer_Ljava_text_FieldPosition_Handler")]
public abstract Java.Lang.StringBuffer Format (long number, Java.Lang.StringBuffer toAppendTo, Java.Text.FieldPosition pos);
[<Android.Runtime.Register("format", "(JLjava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_JLjava_lang_StringBuffer_Ljava_text_FieldPosition_Handler")>]
override this.Format : int64 * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

number
Int64

the long number to format

toAppendTo
StringBuffer

the StringBuffer to which the formatted text is to be appended

pos
FieldPosition

keeps track on the position of the field within the returned string. For example, for formatting a number 123456789 in Locale.US locale, if the given fieldPosition is NumberFormat#INTEGER_FIELD, the begin index and end index of fieldPosition will be set to 0 and 11, respectively for the output string 123,456,789.

Returns

the formatted StringBuffer

Attributes

Remarks

Specialization of format.

Java documentation for java.text.NumberFormat.format(long, 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