Partager via


SimpleDateFormat.Format(Date, StringBuffer, FieldPosition) Method

Definition

Formats the given Date into a date/time string and appends the result to the given StringBuffer.

[Android.Runtime.Register("format", "(Ljava/util/Date;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_Ljava_util_Date_Ljava_lang_StringBuffer_Ljava_text_FieldPosition_Handler")]
public override Java.Lang.StringBuffer? Format (Java.Util.Date? date, Java.Lang.StringBuffer? toAppendTo, Java.Text.FieldPosition? pos);
[<Android.Runtime.Register("format", "(Ljava/util/Date;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_Ljava_util_Date_Ljava_lang_StringBuffer_Ljava_text_FieldPosition_Handler")>]
override this.Format : Java.Util.Date * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

date
Date

the date-time value to be formatted into a date-time string.

toAppendTo
StringBuffer

where the new date-time text is to be appended.

pos
FieldPosition

keeps track on the position of the field within the returned string. For example, given a date-time text "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition is DateFormat#YEAR_FIELD, the begin index and end index of fieldPosition will be set to 0 and 4, respectively. Notice that if the same date-time field appears more than once in a pattern, the fieldPosition will be set for the first occurrence of that date-time field. For instance, formatting a Date to the date-time string "1 PM PDT (Pacific Daylight Time)" using the pattern "h a z (zzzz)" and the alignment field DateFormat#TIMEZONE_FIELD, the begin index and end index of fieldPosition will be set to 5 and 8, respectively, for the first occurrence of the timezone pattern character 'z'.

Returns

the formatted date-time string.

Attributes

Exceptions

if there are invalid characters in the pattern.

Remarks

Formats the given Date into a date/time string and appends the result to the given StringBuffer.

Java documentation for java.text.SimpleDateFormat.format(java.util.Date, 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