Reputation: 5935
I want to use a date and time picker in a BlackBerry app.
Upvotes: 0
Views: 1112
Reputation: 5836
I don't know if you still have this problem but the solution I used is the DateTimePicker
Here's how you do it:
Calendar _dateCal;
SimpleDateFormat _dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
DateTimePicker _datePicker = DateTimePicker.createInstance(_dateCal, "dd-MMM-yyyy", null);
if(_datePicker.doModal())
{
StringBuffer _dateStr = new StringBuffer();
_dateCal = _datePicker.getDateTime();
_dateFormat.format(_dateCal, _dateStr, null);
_setDateButton.setLabel(_dateStr.toString());
}
That will prompt a spinner box for date selection to the screen
Upvotes: 0
Reputation: 28418
Use net.rim.device.api.ui.component.DateField
.
long yourInitialDatetime = System.currentTimeMillis();
DateField dateField = new DateField("Date:", yourInitialDatetime,
DateField.DATE_TIME);
yourScreen.add(dateField);
...
long currentlySelectedDatetime = dateField.getDate();
Upvotes: 1