Partager via


DateUtils.FormatDateTime(Context, Int64, FormatStyleFlags) Method

Definition

Formats a date or a time according to the local conventions.

[Android.Runtime.Register("formatDateTime", "(Landroid/content/Context;JI)Ljava/lang/String;", "")]
public static string? FormatDateTime (Android.Content.Context? context, long millis, Android.Text.Format.FormatStyleFlags flags);
[<Android.Runtime.Register("formatDateTime", "(Landroid/content/Context;JI)Ljava/lang/String;", "")>]
static member FormatDateTime : Android.Content.Context * int64 * Android.Text.Format.FormatStyleFlags -> string

Parameters

context
Context

the context is required only if the time is shown

millis
Int64

a point in time in UTC milliseconds

flags
FormatStyleFlags

a bit mask of formatting options

Returns

a string containing the formatted date/time.

Attributes

Remarks

Formats a date or a time according to the local conventions. There are lots of options that allow the caller to control, for example, if the time is shown, if the day of the week is shown, if the month name is abbreviated, if noon is shown instead of 12pm, and so on. For the complete list of options, see the documentation for #formatDateRange.

Example output strings (date formats in these examples are shown using the US date format convention but that may change depending on the local settings): <ul> <li>10:15am</li> <li>3:00pm</li> <li>3pm</li> <li>3PM</li> <li>08:00</li> <li>17:00</li> <li>noon</li> <li>Noon</li> <li>midnight</li> <li>Midnight</li> <li>Oct 31</li> <li>Oct 31, 2007</li> <li>October 31, 2007</li> <li>10am, Oct 31</li> <li>17:00, Oct 31</li> <li>Wed</li> <li>Wednesday</li> <li>10am, Wed, Oct 31</li> <li>Wed, Oct 31</li> <li>Wednesday, Oct 31</li> <li>Wed, Oct 31, 2007</li> <li>Wed, October 31</li> <li>10/31/2007</li> </ul>

Java documentation for android.text.format.DateUtils.formatDateTime(android.content.Context, long, int).

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