|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--net.rim.device.api.i18n.Format
|
+--net.rim.device.api.i18n.DateFormat
|
+--net.rim.device.api.i18n.SimpleDateFormat
Formats and parses dates in a locale-sensitive manner.
Formatting is done employing a user-defined pattern string constructed some or all of the following symbols:
| Symbol | Meaning | Presentation | Example |
|---|---|---|---|
| y | year | (Number) | 1996 |
| M | month in year | (Text & Number) | July & 07 |
| d | day in month | (Number) | 10 |
| h | hour in am/pm (1~12) | (Number) | 12 |
| H | hour in day (0~23) | (Number) | 0 |
| m | minute in hour | (Number) | 30 |
| s | second in minute | (Number) | 55 |
| S | millisecond | (Number) | 978 |
| E | day in week | (Text) | Tuesday |
| a | am/pm marker | (Text) | PM |
| z | time zone | (Text) | Pacific Standard Time |
| ' | escape for text | (Delimiter) | |
| '' | single quote | (Literal) | ' |
The following are not implemented due to CLDC limitations in the Calendar class;
These will all insert "NI":
| Symbol | Meaning | Presentation | Example |
|---|---|---|---|
| G | era designator | (Text) | CE |
| D | day in year | (Number) | 189 |
| F | day of week in month | (Number) | 2 (2nd Wed in July) |
| w | week in year | (Number) | 27 |
| W | week in month | (Number) | 2 |
Any non-alphabetic symbols in the pattern are passed on as if these were quoted text.
Most patterns require or are affected by a length.
| Symbol | Pattern | Example | Example |
|---|---|---|---|
| y | yyyy | 1996 | |
| yy | 96 | ||
| M | M | 7 | |
| MM | 07 | ||
| MMM | Jul | ||
| MMMM | July | ||
| d | d | 9 | |
| dd | 09 | ||
| h | h | 9 | 2 |
| hh | 09 | 02 | |
| H | H | 9 | 14 |
| HH | 09 | 14 | |
| m | m | 7 | 30 |
| mm | 07 | 30 | |
| s | s | 3 | 55 |
| ss | 03 | 55 | |
| S | S | 978 | 4 |
| SS | 978 | 04 | |
| SSS | 978 | 004 | |
| E | E, EE, EEE | Tue | |
| EEEE | Tuesday | ||
| a | a | p | |
| aa | PM | ||
| z | z | Pacific Standard Time |
Compatible with java.text.SimpleDateFormat in Java's standard edition.
| Field Summary |
| Fields inherited from class net.rim.device.api.i18n.DateFormat |
AM_PM_FIELD, DATE_DEFAULT, DATE_FIELD, DATE_FULL, DATE_LONG, DATE_MEDIUM, DATE_SHORT, DATETIME_DEFAULT, DAY_OF_WEEK_FIELD, ERA_FIELD, GUID_DATE_FORMAT_CHANGED, HOUR_FIELD, HOUR_OF_DAY_FIELD, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, SECOND_FIELD, TIME_DEFAULT, TIME_FULL, TIME_LONG, TIME_MEDIUM, TIME_SHORT, TIMEZONE_FIELD, YEAR_FIELD |
| Constructor Summary | ||
SimpleDateFormat(int style)
Constructs new SimpleDateFormat instance with provided style. |
||
SimpleDateFormat(String pattern)
Constructs a new SimpleDateFormat instance with provided pattern string. |
||
| Method Summary | ||
void |
applyPattern(int style)
Applies a date/time format style to this formatter. |
|
void |
applyPattern(String pattern)
Applies a date/time pattern string to this formatter. |
|
StringBuffer |
format(Calendar calendar,
StringBuffer toAppendTo_o,
FieldPosition pos_io)
Retrieves formatted string representation of calendar object. |
|
int[] |
getFields()
Retrieves ordered list of fields. |
|
String |
toPattern()
Returns a pattern string describing this formatter's current format style. |
|
| Methods inherited from class net.rim.device.api.i18n.DateFormat |
format, formatLocal, formatLocal, getInstance |
| Methods inherited from class net.rim.device.api.i18n.Format |
format |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SimpleDateFormat(int style)
See DateFormat for the date/time format styles you should
choose from.
style - Date/time format style for this formatterpublic SimpleDateFormat(String pattern)
Note: Instead of building a simple date formatter
with this constructor, use DateFormat.getInstance(int) to retrieve the
simple formatter in the particular style you want.
DateFormat| Method Detail |
public void applyPattern(int style)
See DateFormat for the date/time format styles you should
choose from.
style - Date/time format style for this formatter.public void applyPattern(String pattern)
pattern - Pattern string to use with this formatter (see this
class's description for the supported characters in a pattern string).public StringBuffer format(Calendar calendar, StringBuffer toAppendTo_o, FieldPosition pos_io)
This method uses this formatter's current style to format the date contained in your calendar object, placing the result in a string buffer.
format in class DateFormatcalendar - Calendar object containing the date to format.toAppendTo_o - String buffer to hold the formatted results.pos_io - If not null, this method invokes getFields() and
sets the begin/end for the field during formatting.public String toPattern()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2007 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.