Added in API level 3

DateFormat


public class DateFormat
extends Object

java.lang.Object
   ↳ android.text.format.DateFormat


Utility class for producing strings with formatted date/time.

Most callers should avoid supplying their own format strings to this class' format methods and rely on the correctly localized ones supplied by the system. This class' factory methods return appropriately-localized DateFormat instances, suitable for both formatting and parsing dates. For the canonical documentation of format strings, see SimpleDateFormat.

In cases where the system does not provide a suitable pattern, this class offers the getBestDateTimePattern(Locale, String) method.

The format methods in this class implement a subset of Unicode UTS #35 patterns. The subset currently supported by this class includes the following format characters: acdEHhLKkLMmsyz. Up to API level 17, only adEhkMmszy were supported. Note that this class incorrectly implements k as if it were H for backwards compatibility.

See SimpleDateFormat for more documentation about patterns, or if you need a more complete or correct implementation. Note that the non-format methods in this class are implemented by SimpleDateFormat.

Summary

Public constructors

DateFormat()

Public methods

static CharSequence format(CharSequence inFormat, Calendar inDate)

Given a format string and a Calendar object, returns a CharSequence containing the requested date.

static CharSequence format(CharSequence inFormat, Date inDate)

Given a format string and a Date object, returns a CharSequence containing the requested date.

static CharSequence format(CharSequence inFormat, long inTimeInMillis)

Given a format string and a time in m