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(Date) |
Formats a |
| Format(Object, StringBuffer, FieldPosition) |
Formats the given |
| Format(Date, StringBuffer, FieldPosition) |
Formats a |
Format(Date)
Formats a Date into a date-time string.
[Android.Runtime.Register("format", "(Ljava/util/Date;)Ljava/lang/String;", "")]
public string Format(Java.Util.Date date);
[<Android.Runtime.Register("format", "(Ljava/util/Date;)Ljava/lang/String;", "")>]
override this.Format : Java.Util.Date -> string
Parameters
- date
- Date
the time value to be formatted into a date-time string.
Returns
the formatted date-time string.
- Attributes
Remarks
Formats a Date into a date-time string.
Java documentation for java.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(Object, StringBuffer, FieldPosition)
Formats the given Object into a date-time string.
[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 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;", "")>]
override this.Format : Java.Lang.Object * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer
Parameters
- obj
- Object
Must be a Date or a Number representing a
millisecond offset from the Epoch.
- toAppendTo
- StringBuffer
The string buffer for the returning date-time string.
- fieldPosition
- 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 string buffer passed in as toAppendTo,
with formatted text appended.
- Attributes
Exceptions
if object is neither a Date nor a
Number instance.
Remarks
Formats the given Object into a date-time string. The formatted string is appended to the given StringBuffer.
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")]
public abstract 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")>]
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 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 string buffer passed in as toAppendTo, with formatted
text appended.
- Attributes
Remarks
Formats a Date into a date-time string. The formatted string is appended to the given StringBuffer.
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.