DateFormat.Format Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Format(Object, StringBuffer, FieldPosition) |
Formats a time object into a time string. |
Format(Date, StringBuffer, FieldPosition) |
Formats a Date into a date/time string. |
Format(Date) |
Formats a Date into a date/time string. |
Format(Calendar, StringBuffer, FieldPosition) |
Formats a date into a date/time string. |
Format(Object, StringBuffer, FieldPosition)
Formats a time object into a time string.
[Android.Runtime.Register("format", "(Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)]
public override sealed Java.Lang.StringBuffer? Format (Java.Lang.Object? obj, Java.Lang.StringBuffer? toAppendTo, Java.Text.FieldPosition? fieldPosition);
[<Android.Runtime.Register("format", "(Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)>]
override this.Format : Java.Lang.Object * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer
Parameters
- obj
- Object
must be a Number or a Date or a Calendar.
- toAppendTo
- StringBuffer
the string buffer for the returning time string.
- fieldPosition
- FieldPosition
keeps track of the position of the field within the returned string. On input: an alignment field, if desired. On output: the offsets of the alignment field. For example, given a 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 time field appears more than once in a pattern, the fieldPosition will be set for the first occurrence of that time field. For instance, formatting a Date to the 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 time string.
- Attributes
Remarks
Formats a time object into a time string. Examples of time objects are a time value expressed in milliseconds and a Date object.
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(Date, StringBuffer, FieldPosition)
Formats a Date into a date/time string.
[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", ApiSince=24)]
public virtual Java.Lang.StringBuffer? Format (Java.Util.Date? date, Java.Lang.StringBuffer? toAppendTo, Java.Text.FieldPosition? fieldPosition);
[<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", ApiSince=24)>]
override this.Format : Java.Util.Date * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer
Parameters
- date
- Date
a Date to be formatted into a date/time string.
- toAppendTo
- StringBuffer
the string buffer for the returning date/time string.
- fieldPosition
- FieldPosition
keeps track of the position of the field within the returned string. On input: an alignment field, if desired. On output: the offsets of the alignment field. For example, given a 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 time field appears more than once in a pattern, the fieldPosition will be set for the first occurrence of that time field. For instance, formatting a Date to the 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
Remarks
Formats a Date into a date/time string.
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(Date)
Formats a Date into a date/time string.
[Android.Runtime.Register("format", "(Ljava/util/Date;)Ljava/lang/String;", "", ApiSince=24)]
public string? Format (Java.Util.Date? date);
[<Android.Runtime.Register("format", "(Ljava/util/Date;)Ljava/lang/String;", "", ApiSince=24)>]
override this.Format : Java.Util.Date -> string
Parameters
- date
- Date
the time value to be formatted into a time string.
Returns
the formatted time string.
- Attributes
Remarks
Formats a Date into a date/time string.
Java documentation for android.icu.text.DateFormat.format(java.util.Date)
.
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(Calendar, StringBuffer, FieldPosition)
Formats a date into a date/time string.
[Android.Runtime.Register("format", "(Landroid/icu/util/Calendar;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_Landroid_icu_util_Calendar_Ljava_lang_StringBuffer_Ljava_text_FieldPosition_Handler", ApiSince=24)]
public abstract Java.Lang.StringBuffer? Format (Android.Icu.Util.Calendar? cal, Java.Lang.StringBuffer? toAppendTo, Java.Text.FieldPosition? fieldPosition);
[<Android.Runtime.Register("format", "(Landroid/icu/util/Calendar;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "GetFormat_Landroid_icu_util_Calendar_Ljava_lang_StringBuffer_Ljava_text_FieldPosition_Handler", ApiSince=24)>]
override this.Format : Android.Icu.Util.Calendar * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer
Parameters
- cal
- Calendar
a Calendar set to the date and time to be formatted into a date/time string. When the calendar type is different from the internal calendar held by this DateFormat instance, the date and the time zone will be inherited from the input calendar, but other calendar field values will be calculated by the internal calendar.
- toAppendTo
- StringBuffer
the string buffer for the returning date/time string.
- fieldPosition
- FieldPosition
keeps track of the position of the field within the returned string. On input: an alignment field, if desired. On output: the offsets of the alignment field. For example, given a 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 time field appears more than once in a pattern, the fieldPosition will be set for the first occurrence of that time field. For instance, formatting a Date to the 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
Remarks
Formats a date into a date/time string.
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.