|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.pim.DateFormat
public class DateFormat
Utility class for producing strings with formatted date/time.
This class takes as inputs a format string and a representation of a date/time. The format string controls how the output is generated.
Formatting characters may be repeated in order to get more detailed representations of that field. For instance, the format character 'M' is used to represent the month. Depending on how many times that character is repeated you get a different representation.
For the month of September:
M -> 9
MM -> 09
MMM -> Sep
MMMM -> September
The effects of the duplication vary depending on the nature of the field.
See the notes on the individual field formatters for details. For purely numeric
fields such as HOUR adding more copies of the designator will
zero-pad the value to that number of characters.
For 7 minutes past the hour:
m -> 7
mm -> 07
mmm -> 007
mmmm -> 0007
Examples for April 6, 1970 at 3:23am:
"MM/dd/yy h:mmaa" -> "04/06/70 3:23am"
"MMM dd, yyyy h:mmaa" -> "Apr 6, 1970 3:23am"
"MMMM dd, yyyy h:mmaa" -> "April 6, 1970 3:23am"
"E, MMMM dd, yyyy h:mmaa" -> "Mon, April 6, 1970 3:23am&
"EEEE, MMMM dd, yyyy h:mmaa" -> "Monday, April 6, 1970 3:23am"
"'Best day evar: 'M/d/yy" -> "Best day evar: 4/6/70"
| Field Summary | |
|---|---|
static char |
AM_PM
This designator indicates whether the HOUR field is before
or after noon. |
static char |
CAPITAL_AM_PM
This designator indicates whether the HOUR field is before
or after noon. |
static char |
DATE
This designator indicates the day of the month. |
static char |
DAY
This designator indicates the name of the day of the week. |
static char |
HOUR
This designator indicates the hour of the day in 12 hour format. |
static char |
HOUR_OF_DAY
This designator indicates the hour of the day in 24 hour format. |
static char |
MINUTE
This designator indicates the minute of the hour. |
static char |
MONTH
This designator indicates the month of the year Examples for September: M -> 9 MM -> 09 MMM -> Sep MMMM -> September |
static char |
QUOTE
Text in the format string that should be copied verbatim rather that interpreted as formatting codes must be surrounded by the QUOTE
character. |
static char |
SECONDS
This designator indicates the seconds of the minute. |
static char |
TIME_ZONE
This designator indicates the offset of the timezone from GMT. |
static char |
YEAR
This designator indicates the year. |
| Constructor Summary | |
|---|---|
DateFormat()
|
|
| Method Summary | |
|---|---|
static CharSequence |
format(CharSequence inFormat,
Calendar inDate)
|
static CharSequence |
format(CharSequence inFormat,
Date inDate)
|
static CharSequence |
format(CharSequence inFormat,
long inTimeInMillis)
|
static DateFormat |
getDateFormat(Context context)
Returns a DateFormat object that can format the date according
to the current user preference. |
static char[] |
getDateFormatOrder(Context context)
Gets the current date format stored as a char array. |
static DateFormat |
getLongDateFormat(Context context)
Returns a DateFormat object that can format the date
in long form (such as December 31, 1999) based on user preference. |
static DateFormat |
getTimeFormat(Context context)
Returns a DateFormat object that can format the time according
to the current user preference. |
static boolean |
is24HourFormat(Context context)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char QUOTE
QUOTE
character. If you need to embed a literal QUOTE character in
the output text then use two in a row.
public static final char AM_PM
HOUR field is before
or after noon. The output is lower-case.
Examples:
a -> a or p
aa -> am or pm
public static final char CAPITAL_AM_PM
HOUR field is before
or after noon. The output is capitalized.
Examples:
A -> A or P
AA -> AM or PM
public static final char DATE
public static final char DAY
public static final char HOUR
public static final char HOUR_OF_DAY
public static final char MINUTE
public static final char MONTH
public static final char SECONDS
public static final char TIME_ZONE
public static final char YEAR
| Constructor Detail |
|---|
public DateFormat()
| Method Detail |
|---|
public static boolean is24HourFormat(Context context)
public static final DateFormat getTimeFormat(Context context)
DateFormat object that can format the time according
to the current user preference.
context - the application context
DateFormat object that properly formats the time.public static final DateFormat getDateFormat(Context context)
DateFormat object that can format the date according
to the current user preference.
context - the application context
DateFormat object that properly formats the date.public static final DateFormat getLongDateFormat(Context context)
DateFormat object that can format the date
in long form (such as December 31, 1999) based on user preference.
context - the application context
DateFormat object that formats the date in long form.public static final char[] getDateFormatOrder(Context context)
DATE, MONTH, and YEAR) in the order
preferred by the user.
public static final CharSequence format(CharSequence inFormat,
long inTimeInMillis)
public static final CharSequence format(CharSequence inFormat,
Date inDate)
public static final CharSequence format(CharSequence inFormat,
Calendar inDate)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||