Java.Text.DateFormat Class
Formats or parses dates and times.

See Also: DateFormat Members

Syntax

[Android.Runtime.Register("java/text/DateFormat", DoNotGenerateAcw=true)]
public abstract class DateFormat : _Format

Remarks

Formats or parses dates and times.

This class provides factories for obtaining instances configured for a specific locale. The most common subclass is Java.Text.SimpleDateFormat.

Sample Code

This code:

java Example

 DateFormat[] formats = new DateFormat[] {
   DateFormat.getDateInstance(),
   DateFormat.getDateTimeInstance(),
   DateFormat.getTimeInstance(),
 };
 for (DateFormat df : formats) {
   System.out.println(df.format(new Date(0)));
   df.setTimeZone(TimeZone.getTimeZone("UTC"));
   System.out.println(df.format(new Date(0)));
 }
 

Produces this output when run on an en_US device in the America/Los_Angeles time zone:

java Example

 Dec 31, 1969
 Jan 1, 1970
 Dec 31, 1969 4:00:00 PM
 Jan 1, 1970 12:00:00 AM
 4:00:00 PM
 12:00:00 AM
 
And will produce similarly appropriate localized human-readable output on any user's system. Notice how the same point in time when formatted can appear to be a different time when rendered for a different time zone. This is one reason why formatting should be left until the data will only be presented to a human. Machines should interchange "Unix time" integers.

[Android Documentation]

Requirements

Namespace: Java.Text
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1