net.rim.device.api.i18n
Class SimpleDateFormat
java.lang.Object
|
+--net.rim.device.api.i18n.Format
|
+--net.rim.device.api.i18n.DateFormat
|
+--net.rim.device.api.i18n.SimpleDateFormat
- public class SimpleDateFormat
- extends DateFormat
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
|
|---|
| G | era designator | (Text) | CE
|
| 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
|
| 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
|
| a | am/pm marker | (Text) | PM
|
| z | time zone | (Text) | Pacific Standard Time
|
| ' | escape for text | (Delimiter) |
|
| '' | single quote | (Literal) | '
|
Any non-alphabetic symbols in the pattern are passed on as if these
were quoted text.
Compatible with
java.text.SimpleDateFormat
in Java's standard edition.
| 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.
|
| Methods inherited from class net.rim.device.api.i18n.Format |
format |
SimpleDateFormat
public SimpleDateFormat(int style)
- Constructs new SimpleDateFormat instance with provided style.
See DateFormat for the date/time format styles you should
choose from.
- Parameters:
style - Date/time format style for this formatter
SimpleDateFormat
public SimpleDateFormat(String pattern)
- Constructs a new SimpleDateFormat instance with provided pattern string.
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.
- See Also:
DateFormat
applyPattern
public void applyPattern(int style)
- Applies a date/time format style to this formatter.
See DateFormat for the date/time format styles you should
choose from.
- Parameters:
style - Date/time format style for this formatter.- Since:
- JDE 3.6
applyPattern
public void applyPattern(String pattern)
- Applies a date/time pattern string to this formatter.
- Parameters:
pattern - Pattern string to use with this formatter (see this
class's description for the supported characters in a pattern string).- Since:
- JDE 3.6
format
public StringBuffer format(Calendar calendar,
StringBuffer toAppendTo_o,
FieldPosition pos_io)
- Retrieves formatted string representation of calendar object.
This method uses this formatter's current style to format the date
contained in your calendar object, placing the result in a string buffer.
- Overrides:
format in class DateFormat
- Parameters:
calendar - 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.- Returns:
- String buffer containing formatted string representation of object.
- Since:
- JDE 3.6
getFields
public int[] getFields()
- Retrieves ordered list of fields.
- Overrides:
getFields in class Format
- Returns:
- List of field identifiers for the fields in this formatter's
format string, ordered left to right.
toPattern
public String toPattern()
- Returns a pattern string describing this formatter's current format style.
- Returns:
- Pattern string representing this formatter's current format style.
Copyright 1999-2002 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.