|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.picker.DateTimePicker
public abstract class DateTimePicker
A user interface component for picking a date only, time only, and date and time together.
This API can support various options for capturing dates and times.
This includes capturing partial dates such as credit card expiry dates which include only a month and a year.
This class handles insufficient information for dates in the same way Calendar
does.
The developer specifies which parts of the date are mutable by specifying a format.
Likewise, the developer is responsible for retrieving the particular data she
is interested in. For example, selecting credit card expiry dates, the developer
would retrieve only the month and the year from DateTimePicker.getDateTime()
.
It is important to note that certain formatting may not fit or look appropriate on the screen. For example, using DateFormat.DATE_FULL may not display properly on all devices because of the width of the date. It is the API user's responsibility to provide a format suitable for the device's display.
To display the date and time picker, invoke DateTimePicker.doModal()
from the event thread.
final DateTimePicker datePicker = DateTimePicker.createInstance();
datePicker.doModal();
final DateTimePicker datePicker = DateTimePicker.createInstance( Calendar.getInstance(), "yyyy-MM-dd", null);
datePicker.doModal();
final DateTimePicker datePicker = DateTimePicker.createInstance( Calendar.getInstance(), null, "hh:mm:ss aa");
datePicker.doModal();
final DateTimePicker datePicker = DateTimePicker.createInstance( Calendar.getInstance(), DateFormat.DATE_FULL, -1);
datePicker.doModal();
final DateTimePicker datePicker = DateTimePicker.createInstance( Calendar.getInstance(), "MM/yyyy", null);
datePicker.doModal();
final java.util.Calendar cal = datePicker.getDateTime();
final int month = cal.get(Calendar.MONTH);
final int year = cal.get(Calendar.YEAR);
Calendar
,
DateFormat
Method Summary | ||
---|---|---|
static Calendar |
cloneCalendar(Calendar source)
Clones a Calendar . |
|
static void |
cloneCalendar(Calendar source,
Calendar destination)
Clone a Calendar object. |
|
static DateTimePicker |
createInstance()
Returns a date picker with the cuurent date using the default style. |
|
static DateTimePicker |
createInstance(Calendar calendar)
Returns a date picker with an initial date to display, and default format. |
|
static DateTimePicker |
createInstance(Calendar calendar,
int dateStyle,
int timeStyle)
Returns a date picker with an initial date to display, and the format for the date and time. |
|
static DateTimePicker |
createInstance(Calendar calendar,
String datePattern,
String timePattern)
Returns a date picker with an initial date to display, and the format for the date and time. |
|
boolean |
doModal()
Show the DatePicker in a modal screen centered on the display. |
|
boolean |
doModal(int initialFocusField)
Show the DatePicker in a modal screen and also set the field which has the initial focus. |
|
abstract boolean |
doModal(int initialFocusField,
XYRect preferredPosition)
Show the DatePicker in a modal screen on a specific position with an initial field to focus. |
|
abstract Calendar |
getDateTime()
Returns the calendar's current date and time as a Calendar object. |
|
abstract void |
reset()
Resets the picker to the initial date. |
|
abstract void |
setDateTime(Calendar calendar)
Sets the date of the picker to the specified date. |
|
void |
setIncrement(int calendarField,
int incrementAmount)
Sets the increment for a specific date/time field. |
|
abstract void |
setMaximumDate(Calendar maxCalendar)
Sets the maximum date that can be selected by this picker. |
|
abstract void |
setMinimumDate(Calendar minCalendar)
Sets the minimum date that can be selected by this picker. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static DateTimePicker createInstance()
DateFormat.DATE_DEFAULT
Time format set to DateFormat.TIME_DEFAULT
DateTimePicker
with the current date and default stylepublic static DateTimePicker createInstance(Calendar calendar)
DateFormat.DATE_DEFAULT
Time format set to DateFormat.TIME_DEFAULT
calendar
- initial date to display
DateTimePicker
with the initial date set and default stylepublic static DateTimePicker createInstance(Calendar calendar, int dateStyle, int timeStyle)
It is important to note that certain formatting may not fit or look appropriate on the screen. For example, using DateFormat.DATE_FULL may not display properly on all devices because of the width of the date. It is the API user's responsibility to provide a format suitable for the device's display.
calendar
- initial date to displaydateStyle
- one of DateFormat.DATE_FULL, DateFormat.DATE_LONG, DateFormat.DATE_MEDIUM, DateFormat.DATE_SHORT, DateFormat.DATE_DEFAULT.
If an invalid dateStyle
, then DateFormat.DATE_DEFAULT is used.timeStyle
- one of DateFormat.TIME_FULL, DateFormat.TIME_LONG, DateFormat.TIME_MEDIUM, DateFormat.TIME_SHORT, DateFormat.TIME_DEFAULT.
If an invalid timeStyle
, then DateFormat.TIME_DEFAULT is used.
DateTimePicker
with the initial date and style setpublic static DateTimePicker createInstance(Calendar calendar, String datePattern, String timePattern)
It is important to note that certain formatting may not fit or look appropriate on the screen. For example, using DateFormat.DATE_FULL may not display properly on all devices because of the width of the date. It is the API user's responsibility to provide a format suitable for the device's display.
calendar
- initial date to displaydatePattern
- the SimpleDateFormat
for the date.
If datePattern is null and timePattern is not null, then a date will not be shown.
The pattern must only include text patterns (e.g. '/',':') and date patterns i.e.
DateFormat.YEAR_FIELD, DateFormat.MONTH_FIELD, DateFormat.DATE_FIELD, DateFormat.DAY_OF_WEEK_FIELD.
Other format symbols will be ignored.timePattern
- the SimpleDateFormat
for the time. Passing null will not show a time
If timePattern is null and datePattern is not null, then a time will not be shown.
The pattern must only include text patterns (e.g. '/',':') and any of the following time patterns:
DateFormat.HOUR_FIELD, DateFormat.HOUR_OF_DAY_FIELD, DateFormat.MINUTE_FIELD, DateFormat.SECOND_FIELD, DateFormat.AM_PM_FIELD.
Other format symbols will be ignored.
DateTimePicker
with the initial date and style setpublic abstract Calendar getDateTime()
Calendar
object.
Calendar
object.public abstract void reset()
public abstract void setMinimumDate(Calendar minCalendar)
minCalendar
- the minimum date
NullPointerException
- if minCalendar
is nullpublic abstract void setMaximumDate(Calendar maxCalendar)
maxCalendar
- the maximum date
NullPointerException
- if maxCalendar
is null.public abstract void setDateTime(Calendar calendar)
calendar
- the date to set the picker to.public void setIncrement(int calendarField, int incrementAmount)
calendarField
- supported fields include Calendar.MINUTE
and Calendar.SECOND
.incrementAmount
- the amount to increment e.g. if the increment is 5 for Calendar.MINUTE
,
then the available numbers will be 0, 5, 10, 15, ...public boolean doModal()
public abstract boolean doModal(int initialFocusField, XYRect preferredPosition)
initialFocusField
- One of the integers from DateFormat
e.g. YEAR_FIELD
.
Use -1
to use the default focus.preferredPosition
- the preferred position of the modal screen.
public boolean doModal(int initialFocusField)
initialFocusField
- One of the integers from DateFormat
e.g. YEAR_FIELD
.
Use -1
to use the default focus.
public static void cloneCalendar(Calendar source, Calendar destination)
Calendar
object.
source
- Calendar
to clone. If null, nothing is copied over to destination.destination
- clone of source Calendar
; If null, nothing is done.public static Calendar cloneCalendar(Calendar source)
Calendar
.
source
- the source celendar
source
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal